Monday, April 28, 2008

query and kill oracle connection session

List all sessions:

     SQL> SELECT s.sid, s.serial#, s.osuser, s.program FROM v$session s; 

Find current session

     SQL> select sid from v$session where audsid= userenv('SESSIONID'); 

Kill one session:

Issuing the ALTER SYSTEM KILL SESSION command is the only safe way to kill an Oracle session. If the marked session persists for some time you may consider killing the process at the operating system level, as explained below. Killing OS processes is dangerous and can lead to instance failures, so do this at your own peril.
It is possible to force the kill by adding the IMMEDIATE keyword:

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

No comments:

CNOUG.net