Skip to content

Instantly share code, notes, and snippets.

@wkoszycki
Last active September 23, 2015 08:40
Show Gist options
  • Save wkoszycki/584c90ffc7bae60e0245 to your computer and use it in GitHub Desktop.
Save wkoszycki/584c90ffc7bae60e0245 to your computer and use it in GitHub Desktop.
kill blocking session oracle
SELECT 'ALTER SYSTEM KILL SESSION '''||sid||','|| s.serial#||'''IMMEDIATE;'
FROM sys.GV_$LOCKED_OBJECT L
, DBA_OBJECTS O
, sys.GV_$SESSION S
, sys.GV_$PROCESS P
WHERE L.OBJECT_ID = O.OBJECT_ID
and l.inst_id = s.inst_id
AND L.SESSION_ID = S.SID
and s.inst_id = p.inst_id
AND S.PADDR = P.ADDR(+)
order by l.inst_id;
SELECT 'ALTER SYSTEM KILL SESSION '''||sid||','|| serial#||'''IMMEDIATE;' FROM v$session WHERE blocking_session is not NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment