Saturday, December 28, 2013

How to kill the INACTIVE database Session

Find the inactive session:

To find the inactive session from the database to executing below query
 

SELECT s.inst_id, s.sid, s.serial#, p.spid, s.username, s.program FROM gv$session s JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id WHERE s.type != 'BACKGROUND';

Kill the session:

To kill the session use the below script

 SQL> ALTER SYSTEM KILL SESSION 'sid,serial#';

Note:
Killing sessions can be very destructive if you kill the wrong session, so be very careful when identifying the session to be killed. If you kill a session belonging to a background process you will cause an instance crash.


References 
How to Check if Dead Connection Detection (DCD) is Enabled in 9i ,10g and 11g (Doc ID 395505.1
Dead Connection Detection (DCD) Explained (Doc ID 151972.1 

Why several Process remain KILLED in V$SESSION (Doc ID 107686.1

No comments:

Post a Comment