Killing Oracle Session



The KILL SESSION clause lets you mark a session as terminated, roll back ongoing transactions, release all session locks, and partially recover session resources.

SELECT s.SID, s.serial#, s.osuser, s.program
  FROM v$session s;

The command for killing session is:

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

Specify IMMEDIATE to instruct Oracle Database to roll back ongoing transactions, release all session locks, recover the entire session state, and return control to you immediately.

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

In some situations particular session is not able to kill the session immediately. In these cases the session will be "marked for kill". It will then be killed as soon as possible.

Kill Session Process

SELECT s.SID, p.spid, s.osuser, s.program
  FROM v$process p, v$session s
 WHERE p.addr = s.paddr;
        SID SPID         OSUSER                         PROGRAM
---------- ------------ ------------------------------ ------------------------------------------------
       159 9244         john                           TOAD.exe
       119 17519        root                           perl@192.168.1.20 (TNS V1-V3)
       119 17518        root                           perl@192.168.1.20 (TNS V1-V3)
        54 1944         john                           TOAD.exe
        13 1299         john                           TOAD.exe
        30 6495         john                           sqlplus.exe

For windows:

C:> orakill ORACLE_SID spid

For Unix:

% kill -9 spid