Monday, 18 October 2010

how to kill an Oracle session

If I want to kill an Oracle database session, in a UNIX environment, I usually do it like this:
1. I take the sessions SPID from an sql like this one:
SELECT ses.sid,
       ses.username,
       ses.status,
       pr.spid
  FROM v$session ses, v$process pr
 WHERE ses.paddr = pr.addr

Or with any other method to see the sessions SID and SPID.
Note down the SPID for the respective SID
2. Connect to the OS with a terminal and run the following command:

kill -9  noted_spid

The thing is that every session in the database is a process in the OS, on a DEDICATED server. So it can be killed from the OS directly.

3 comments:

  1. And for Windows SO we can use:
    >orakill

    ReplyDelete
  2. >orakill sid spid

    We can obtain sid and spid from sql described by AndreiM.

    ReplyDelete
  3. But if we have a session that is killed and doesn't have a spid and we try to killed using the kill command:
    alter system kill session 'sid,serial#';

    and this doens't work?:)
    How can we kill it?

    ReplyDelete