Sunday, January 20, 2013

Identify and Kill Specific Session in the database

Perform the below mentioned steps by sys or system user
  1. Find out specific SID and Serial# for a particular session from the v$session view and then use
  2. Alter system kill session .... command to kill the session

SQL> connect sys/change_on_install
Connected.
SQL> alter session set nls_date_format='DD-MON-YYYY:HH24:MI:SS';
Session altered.
SQL> select username, sid, serial#, terminal, program, status, logon_time from v
$session where username = 'OPS$OPAPPS'
SQL> /
USERNAME                              SID    SERIAL# TERMINAL
------------------------------ ---------- ---------- ----------------
PROGRAM                                                            STATUS
---------------------------------------------------------------- --------
LOGON_TIME
--------------------------
OPS$OPAPPS                             14       6114 OCDEV2
                                                                 INACTIVE
29-MAR-2006:15:00:13
OPS$OPAPPS                             16        929 OCDEV2
javaw.exe                                                        INACTIVE
29-MAR-2006:14:58:28

2 rows selected.

SQL> alter system kill session '16,929';
System altered.
SQL> select username, sid, serial#, terminal, program, status, logon_time from v
$session where username = 'OPS$OPAPPS';
USERNAME                              SID    SERIAL# TERMINAL
------------------------------ ---------- ---------- ----------------
PROGRAM                                                          STATUS
---------------------------------------------------------------- --------
LOGON_TIME
--------------------------
OPS$OPAPPS                             14       6114 OCDEV2
                                                                 INACTIVE
29-MAR-2006:15:00:13
OPS$OPAPPS                             16        929 OCDEV2
javaw.exe                                                        KILLED
29-MAR-2006:14:58:28

2 rows selected.

No comments:

Post a Comment