SET pagesize 55;
SET linesize 170;
col SQL format a80;
col SERVER heading 'SVR' format a3;
col EVENT heading 'WAITING' format a30 fold_after;
col OSUSER heading 'OSUSER' format a8;
col USERNAME heading 'USERNAME' format a8;
col PID heading 'OSPID' format 99999;
col DISK_READS heading 'DISK I/O' format 99999999;
col BUFFER_GETS heading 'BUFFER|GETS' format 99999999;
SELECT SUBSTR(V$SESSION.USERNAME,1,8) USERNAME,
V$SESSION.OSUSER OSUSER,
-- DECODE(V$SESSION.SERVER,'DEDICATED','D','SHARED','S','O') SERVER,
V$SQLAREA.DISK_READS DISK_READS,
V$SQLAREA.BUFFER_GETS BUFFER_GETS,
SUBSTR(V$SESSION.LOCKWAIT,1,10) LOCKWAIT,
V$SESSION.PROCESS PID,
V$SESSION_WAIT.EVENT EVENT,
V$SQLAREA.SQL_TEXT SQL
FROM V$SESSION_WAIT, V$SQLAREA, V$SESSION
WHERE V$SESSION.SQL_ADDRESS = V$SQLAREA.ADDRESS AND
V$SESSION.SQL_HASH_VALUE = V$SQLAREA.HASH_VALUE AND
V$SESSION.SID = V$SESSION_WAIT.SID (+) AND
V$SESSION.STATUS = 'ACTIVE' AND
V$SESSION_WAIT.EVENT != 'client message'
ORDER BY V$SESSION.LOCKWAIT ASC, V$SESSION.USERNAME;