And to get the details of a particular session given by the sid in the above query use this querySELECT l.inst_id,SUBSTR (L.ORACLE_USERNAME, 1, 8) ORA_USER,SUBSTR (L.SESSION_ID, 1, 3) SID, S.serial#,SUBSTR (O.OWNER || '.' || O.OBJECT_NAME, 1, 40) OBJECT,P.SPID OS_PID,DECODE (L.LOCKED_MODE,0, 'NONE',1, 'NULL',2, 'ROW SHARE',3, 'ROW EXCLUSIVE',4, 'SHARE',5, 'SHARE ROW EXCLUSIVE',6, 'EXCLUSIVE',NULL)LOCK_MODEFROM sys.GV_$LOCKED_OBJECT L,DBA_OBJECTS O,sys.GV_$SESSION S,sys.GV_$PROCESS PWHERE L.OBJECT_ID = O.OBJECT_IDAND l.inst_id = s.inst_idAND L.SESSION_ID = S.SIDAND s.inst_id = p.inst_idAND S.PADDR = P.ADDR(+)ORDER BY l.inst_id;
select STATUS , PROCESS , PROGRAM , LOGON_TIME from v$session where sid=
This will give you queries currently running for more than 60 seconds. Note that it prints multiple lines per running query if the SQL has multiple lines. Look at the sid,serial# to see what belongs together.
SELECT s.username,s.sid,s.serial#,s.last_call_et / 60 mins_running,q.sql_textFROM v$session sJOIN v$sqltext_with_newlines q ON s.sql_address = q.addressWHERE status = 'ACTIVE' AND TYPE <> 'BACKGROUND' AND last_call_et > 60ORDER BY sid, serial#, q.piece