ORACLE会话以及SQL执行信息查询

select t.BLOCKING_SESSION,
       t.SQL_ID,
       t.SID,
       t.SERIAL#,
       t.MACHINE,
       t.PROGRAM,
       t.ACTION,
       t.LOGON_TIME "登录时间",
       trunc((sysdate - t.LOGON_TIME) * 24 * 60 * 60) || 's' "登录时长",
       trunc(nvl(s.ELAPSED_TIME / decode(s.EXECUTIONS, 0, 1, s.EXECUTIONS) /
                 1000000,
                 0),
             2) || 's' 当前SQL每次执行平均耗时,
       t.EVENT#,
       t.EVENT,
       t.WAIT_CLASS,
       t.P1TEXT,
       t.p1,
       s.sql_text,
       s.sql_fulltext
  FROM gv$session t
  left join v$sql s
    on s.sql_id = t.sql_id
   and s.CHILD_NUMBER = t.SQL_CHILD_NUMBER
 WHERE t.STATUS = 'ACTIVE'
   and t.WAIT_CLASS <> 'Idle'
 order by t.SID, t.MACHINE;

 

你可能感兴趣的:(ORACLE)