oracle计算时间秒数差
                        
                            时间:2021-07-01 10:21:17
                            帮助过:6人阅读
							                        
                     
                    
                    
                    计算plsql处理时间差
--qzq
declare
  time1 timestamp;      
--开始时间
  time2 
timestamp;    
--结束时间
  sum1 
number(
9);    
--时间差(s)
begin
  time1 := to_timestamp(to_char(sysdate,
‘yyyy-mm-dd hh24-mi-ss‘),
‘yyyy-mm-dd hh24:mi:ss.ff9‘);
  --处理任务
  for i 
in 1..
600000 loop 
       select 1 into sum1 
from dual;
  end loop;
  time2 := to_timestamp(to_char(sysdate,
‘yyyy-mm-dd hh24-mi-ss‘),
‘yyyy-mm-dd hh24:mi:ss.ff9‘);
 
  sum1 := abs((trunc(time1 
- 0, 
‘mi‘) 
- trunc((time2 
- 0), 
‘mi‘)) 
* 24 * 60 * 60 + extract(second 
from time1 
- time2));  
  
  dbms_output.put_line(sum1||‘s‘);
end;
 
oracle计算时间秒数差
标签: