Skip to content

Instantly share code, notes, and snippets.

@mllopart
Last active May 23, 2017 16:09
Show Gist options
  • Save mllopart/f59b6fb202c1e12bc8704c7c5baf7681 to your computer and use it in GitHub Desktop.
Save mllopart/f59b6fb202c1e12bc8704c7c5baf7681 to your computer and use it in GitHub Desktop.
Oracle - Query to detect active sessions, in order to kill them :)
/*Query to detect active sessions, in order to kill them in Oracle */
SELECT s.inst_id,
s.sid,
s.serial#,
p.spid,
s.username,
s.osuser,
s.machine,
s.program,
'ALTER SYSTEM KILL SESSION '''||s.sid||','||s.serial#||''' IMMEDIATE;' as cmd
FROM gv$session s
JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE s.type != 'BACKGROUND'
and s.MACHINE <> 'LT076458'
order by s.MACHINE, s.sid, s.SERIAL#;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment