将执行结果输出到CSV文件里

set linesize 1000
set pagesize 1000
set time on timing on
set null '#'
set colsep ','
set trimspool on
set heading on
set echo off

col batchname format a40
col batchstart format a26
col batchend format a26

SPOOL output.csv;

-- 算出执行开始结束时间的间隔

select batchname,to_char(batchstart,'YYYY-MM-DD HH24:MI:SS.FF') batchstart,to_char(batchend,'YYYY-MM-DD HH24:MI:SS.FF')batchend
, EXTRACT(DAY    FROM batchend-batchstart) * 86400
 + EXTRACT(HOUR    FROM batchend-batchstart) *  3600
 + EXTRACT(MINUTE    FROM batchend-batchstart) *    60
 + EXTRACT(SECOND    FROM batchend-batchstart) as time
from hd_tbl hd
where hd.logid > 0
and   hd.batchstart is not null
and   hd.batchend is not null
and   batchname like '%&1%'
and   batchstart > to_date('&2','YYYY-MM-DD HH24:MI:SS')
and   batchend < to_date('&3','YYYY-MM-DD HH24:MI:SS')
union all
select '実行回数',to_char(cnt),'平均時間(秒)',avgts
from (
  select count(*) cnt,
 avg(EXTRACT(DAY    FROM batchend-batchstart) * 86400
 + EXTRACT(HOUR    FROM batchend-batchstart) *  3600
 + EXTRACT(MINUTE    FROM batchend-batchstart) *    60
 + EXTRACT(SECOND    FROM batchend-batchstart)) avgts
from hd_tbl hd
where hd.logid > 0
and   hd.batchstart is not null
and   hd.batchend is not null
and   batchname like '%&1%'
and   batchstart > to_date('&2','YYYY-MM-DD HH24:MI:SS')
and   batchend < to_date('&3','YYYY-MM-DD HH24:MI:SS')
);


spool off
/
exit

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值