DBAtlas · Database operations atlas

Kill a session (kill session)

OracleSessions & Processes

Command

-- First find the session to kill:
SELECT sid, serial#, username, status, machine, program
FROM   v$session
WHERE  username = 'CUSTOMER_APP' AND status = 'ACTIVE';

-- Kill it (starts rollback immediately):
ALTER SYSTEM KILL SESSION '145,12345' IMMEDIATE;

-- If it hangs, the OS process can be terminated:
-- ALTER SYSTEM DISCONNECT SESSION '145,12345' IMMEDIATE;

What it does

Terminates the session with the given SID,SERIAL#; its open transaction is rolled back.

When to use it

To stop a session holding locks, running a runaway query, or leaking connections.

Caution

If there is an open transaction, the rollback can take a long time (it finishes quickly if little work was done). Verify with a query first so you do not kill the wrong SID. Rollback of large DML creates I/O load.

Open in DBAtlas →

Related