变量的应用在spool时
来源:互联网 发布:淘宝企业号如何注册 编辑:程序博客网 时间:2024/04/30 12:13
spool的sql语句很是复杂,为了减少运行时间提高性能,我考虑了首先根据索引找出符合条件的记录总数,并根据总数是否大于0,来对要运行的sql添加条件。
如:
sql> variable a2 number;
sql> select count(*) into :a2 from table where length(zd)=2;
在要运行sql中,select .... from table where ..... and :a2>0;
当然,我们需要谨慎的罗列条件计算出a2,以便让它最大程度的符合我们的要求。总之一切多为了提高性能。
我具体的实例如下:
--每行的字符数目
set linesize 999
--不产生新页
set pagesize 50000
--列的设置
--col username format a4
--col a format 999,999,999
--输出列标题
set heading on
--禁止显示最后一行的计数反馈信息
set feedback off
--执行命令文件时,命令本身是否显示在屏幕上
set echo off
--
set termout off
--清空多余的空格,如:linesize过长
set trimout on
set trimspool on
--以下业务逻辑
......
--var a2,a3
variable a2 number;
variable a3 number;
BEGIN
select count(*) into :a2 from table where length(ztb)=2;
select count(*) into :a3 from table where length(ztb)=3;
end;
/
spool e:/output/tt_clzt_1.txt;
PROMPT xxx值不在指定的yyy表中;
select .....from .... where .... and :a3>0 ;
spool off;
如:
sql> variable a2 number;
sql> select count(*) into :a2 from table where length(zd)=2;
在要运行sql中,select .... from table where ..... and :a2>0;
当然,我们需要谨慎的罗列条件计算出a2,以便让它最大程度的符合我们的要求。总之一切多为了提高性能。
我具体的实例如下:
--每行的字符数目
set linesize 999
--不产生新页
set pagesize 50000
--列的设置
--col username format a4
--col a format 999,999,999
--输出列标题
set heading on
--禁止显示最后一行的计数反馈信息
set feedback off
--执行命令文件时,命令本身是否显示在屏幕上
set echo off
--
set termout off
--清空多余的空格,如:linesize过长
set trimout on
set trimspool on
--以下业务逻辑
......
--var a2,a3
variable a2 number;
variable a3 number;
BEGIN
select count(*) into :a2 from table where length(ztb)=2;
select count(*) into :a3 from table where length(ztb)=3;
end;
/
spool e:/output/tt_clzt_1.txt;
PROMPT xxx值不在指定的yyy表中;
select .....from .... where .... and :a3>0 ;
spool off;
- 变量的应用在spool时
- spool的应用
- 离线阅读应用Spool的放弃继续服务加入Facebook
- spool时关闭回显的问题
- save命令+get命令+start命令+edit命令+spool命令+临时变量+已定义的变量
- sqlplus的spool命令
- spool的简单使用
- spool命令的使用
- oracle的Spool命令
- oracle的Spool命令
- 使用spool的注意事项
- spool
- SPOOL
- spool
- SPOOL
- spool
- oracle—spool—时间变量
- 运行脚本时用"SPOOL"保存运行结果的问题
- 谈谈自己考研复习的计划
- 团队见解
- [转]61条面向对象设计的经验原则
- 一种效率极高的分类算法
- 阿兰·图灵
- 变量的应用在spool时
- 树型问题的解决方法
- Java XML教程
- XML文件到RTF和PDF的转换
- struts中配置过滤文件!
- 情人:)
- Hibernate的JNDI绑定分析
- 路易·郭士纳
- Spring 的魅力