[Back To HomePage and Script Library]

Disclaimer: Use these scripts and/or any recommendations they may contain at your own risk. These scripts may or may not have been tested.

Title: Releasing Exclusive Locks and Killing Sessions From Oracle

Author: Sivasubramaniyan Sundar, a database administrator for KCT - Klang Container
Terminal, in Kualu Lumpur, Port Klang, Malaysia.

This script will release the exclusive lock and kill the session. Often, the user forgets to commit or the application lock process
goes to the background due to some sever or application issue. If that occurs, you can use this script to kill the session
mannualy.

This script is usefull for solving resource busy issues and killing unwanted background process made by exclusive lock.
Source/Text/Comments


Rem This script should be run from SVRMGR or SYS
Rem  How to find the exclusive lock process.
Rem  Note - The sid should be > (System background processes)

SVRMGR>connect internal;

SVRMGR> select a.sid,serial#,process,program,terminal from v$lock a,v$session b where a.lmode=6 and a.sid > 10 and a.sid=b.sid;

SID        SERIAL#    PROCESS   PROGRAM
                 TERMINAL
---------- ---------- --------- ------------------------------------------------
---------------- --------
        28       3966 429467232 F45DBG32.EXE
                 Windows
        46       1438 429481395 PLUS33W.EXE
                 Windows
        50       2502 429461059 F45DBG32.EXE
                 Windows

3 rows selected.

Rem ---- Now i am selecting the secound process -----

SVRMGR> alter system kill session '46,1438';
Statement processed.

SVRMGR> select a.sid,serial#,process,program,terminal from v$lock a,v$session b  where a.lmode=6 and a.sid > 10 and a.sid=b.sid;



SID        SERIAL#    PROCESS   PROGRAM
                 TERMINAL
---------- ---------- --------- ------------------------------------------------
---------------- --------
        28       3966 429467232 F45DBG32.EXE
                 Windows
        50       2502 429461059 F45DBG32.EXE
                 Windows
2 rows selected.

Rem ----- Exit from SVRMGR ------
SVRMGR> exit