Friday, July 26, 2013

Query To Get Active SQL Statements Being Executed


SELECT   SUBSTR (SS.USERNAME, 1, 8) DB_USER,
      SS.OSUSER "OS_USER",
      AR.MODULE || ' @ ' || SS.MACHINE CLIENT,
      SS.PROCESS PID,
      SS.SID,
      TO_CHAR (AR.LAST_LOAD_TIME, 'DD-Mon HH24:MM:SS') LOAD_TIME,
      TR.START_TIME,
      SS.LAST_CALL_ET,
      AR.DISK_READS DISK_READS,
      AR.BUFFER_GETS BUFFER_GETS,
      SUBSTR (SS.LOCKWAIT, 1, 10) LOCKWAIT,
      W.EVENT EVENT,
      SS.STATUS,
      T.SQL_TEXT
FROM   V$SESSION_WAIT W,
     V$SQLAREA AR,
     V$SESSION SS,
     V$TIMER T,
     V$SQLTEXT_WITH_NEWLINES T,
     V$TRANSACTION TR
WHERE    SS.SQL_ADDRESS = AR.ADDRESS
    AND SS.SQL_HASH_VALUE = AR.HASH_VALUE
    AND T.ADDRESS = SS.SQL_ADDRESS
    AND SS.SADDR = TR.SES_ADDR(+)
    AND T.HASH_VALUE = SS.SQL_HASH_VALUE
    AND SS.SID = W.SID(+)
    AND SS.STATUS = 'ACTIVE'
    AND SS.USERNAME <> 'SYSTEM'
ORDER BY   SS.SID, T.PIECE;

No comments:

Post a Comment