Archives mensuelles : juin 2015

Find and kill Oracle Session by ID

If you want to kill a Oracle session you have to find out the session SID and Serial# :


SELECT s.inst_id,
s.sid,
s.serial#,
s.username,
s.osuser,
s.program,
s.status,
round(s.last_call_et/60) minutes,
nvl(s.sql_id, s.prev_sql_id),
(select q.sql_text from GV$SQLAREA q where q.inst_id = s.inst_id and q.sql_id = nvl(s.sql_id, s.prev_sql_id))
FROM GV$SESSION s
WHERE nvl(s.username,'SYS') = 'PANA'
AND s.LAST_CALL_ET > 60
ORDER BY last_call_et desc
;

 

INST_ID SID SERIAL# USERNAME OSUSER PROGRAM STATUS MINUTES SQL_ID SQL_Query
1 77 12717 ORA_USER SYS_USER JDBC Thin Client INACTIVE 3 9c8tu7j63jraa SELECT * FROM MY_TABLE

After that, you can use the ALTER SYSTEM command to kill the selected session :


ALTER SYSTEM KILL SESSION 'sid, serial#';