Scripts:显示数据库中长时间运行的SQL的脚本longtime.sql

来源:互联网 发布:json对象多层嵌套解析 编辑:程序博客网 时间:2024/05/20 10:55
set linesize 333                                                                                                                                      
set pagesize 1000                                                                                                                                     
col event for a30                                                                                                                                     
col sess for a18                                                                                                                                      
col username for a10                                                                                                                                  
col program for a40                                                                                                                                   
alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';                                                                                            
select sysdate from dual;                                                                                                                             
select ss.inst_id||':'||ss.sid||':'||ss.username sess,ss.event,ss.program,ss.p1,ss.p1raw,ss.sql_id, trunc(ss.last_call_et/60) lastcall--,ss.logon_time
  from gv$sesstat st, gv$session ss                                                                                                                   
 where st.STATISTIC#=18 and st.sid = ss.sid                                                                                                           
   and ss.username not in ('SYS','SYSTEM','GOLDENGATE')                                                                                               
   and ss.status = 'ACTIVE'                                                                                                                           
   and st.value <>0  and username is not null                                                                                                         
   --and ss.WAIT_CLASS<>'Idle'                                                                                                                        
   and trunc(ss.last_call_et/60) > 5                                                                                                                  
 order by ss.inst_id,ss.last_call_et desc,st.VALUE desc;
0 0
原创粉丝点击