Killing Oracle Sessions

May 27th, 2009 1 Comment   Posted in Oracle How-To, Oracle Tip

Do you need to kill an Oracle session? There are several way to do this. In SQLPlus simply run:

ALTER SYSTEM KILL SESSION 'sid,serial#';

You can also run:

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

You can also kill sessions from the UNIX level with this command:

kill -9 spid

This is dangerous and should not normally be done. Pick the wrong OS process and you could crash your instance. There may also be time you need to bulk kill Oracle sessions. Simply selecting again v$session will get you the data needed.

select 'ALTER SYSTEM KILL SESSION '''||SID||','||SERIAL#||'''
IMMEDIATE;' from v$session where username = 'DWUSER' and
STATUS = 'ACTIVE';

Then just run the output in SQLPlus. Again be sure you are only killing the sessions you want. Killing the wrong session could terminate your database instance.