long running query monitor with last_call_et

利用v$session中的last_call_et字段可以监控long running query.

select sid, serial#, username, to_char(sysdate-last_call_et/24/60/60,'hh24:mi:ss') started,trunc(last_call_et/60) || ' mins, ' || mod(last_call_et,60) || ' secs' dur,
(select sql_text from v$sql where address = sql_address ) sql_text
  from v$session
where username is not null and last_call_et > 60 and status = 'ACTIVE'
/

你可能感兴趣的:(Scripts)