Tuesday, February 16, 2016

Find & Kill A Session

Find & Kill A Session

SQL>   SELECT b.tablespace,b.segfile#,b.segblk#,b.blocks,a.sid,a.serial#,a.username,a.osuser, a.status
            FROM v$session a,v$sort_usage b WHERE a.saddr = b.session_addr;

TABLESPACE  SEGFILE#    SEGBLK#     BLOCKS  SID   SERIAL#       USERNAME       OSUSER    STATUS
----------------      -----------         ------------        -------      -----     ---------            --------------            --------         -------
TEMP                     0               5515776        128        76     19519          NI_EXT_STR    nibansal         INACTIVE
TEMP                     0               5456512        128        289    4221            VSL9                  visingh           KILLED
TEMP                     0               5438976        128        290    39365         SCOTT1           NBANSAL        KILLED
TEMP                     0               5456384        128        497    1926             AN13                akaushal         KILLED


The command for killing a session :

SQL> ALTER SYSTEM KILL SESSION ' sid,  serial# ';     (or)
SQL> ALTER SYSTEM KILL SESSION ' sid,  serial# '  immediate;
Example:

SQL> ALTER SYSTEM KILL SESSION '76,19519' ;
       (or)
SQL> ALTER SYSTEM KILL SESSION '76,19519'  IMMEDIATE;

For Windows:        C:>  orakill ORACLE_SID spid

For  UNIX :         $   KILL -9 spid;       (get SPID from V$PROCESS)

No comments:

Post a Comment