Skip to content

Instantly share code, notes, and snippets.

@paulofellix
Last active May 20, 2024 23:56
Show Gist options
  • Save paulofellix/affe8b3419ae1aadf8ce4c556d6042a4 to your computer and use it in GitHub Desktop.
Save paulofellix/affe8b3419ae1aadf8ce4c556d6042a4 to your computer and use it in GitHub Desktop.
oracle find lock #database #sql
select 'alter system kill session ' || chr(39) || s.sid || ', ' || s.serial# || chr(39) || ' ' || 'immediate'|| ';', s.inst_id,
'kill -9 ' || p.spid, s.username, s.module
from gv$session s, gv$process p
where p.inst_id = s.inst_id
and p.addr = s.paddr
and s.type <> 'BACKGROUND'
and s.sid in (
SELECT DECODE(request, 0, sid, -1) sid
FROM gV$LOCK
WHERE (id1, id2, TYPE) IN (SELECT id1, id2, TYPE FROM GV$LOCK WHERE lmode = 0)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment