Terminate (kill) specific session on a server

Oracle Database provides command to kill specific session on a server.

Before you begin

Please note that you need dba privilege to access the data in v$session view and kill a session.

Find session ID

First we will identify the session we want to end. We do it by listing all sessions on the server with this query:

select sid,
      serial#,
      osuser,
      machine,
      program,
      module
from v$session

Rows

  • sid - session identifier
  • serial# - session serial number
  • osuser - operating system client user name
  • machine - operating system machine name
  • program - operating system program name
  • module - name of the currently executing module as set by calling the DBMS_APPLICATION_INFO.SET_MODULE procedure

Sample results

You can see session list on our test server. My session sid=58, machine=ls-michalwrobel

sample results

Kill session

Now we will use session identifier (sir) and serial# to kill the session.

alter system kill session 'sid,serial#'

In our example we will kill session sid=99, serial#=98.

alter system kill session '99,98'

Result

Oracle Database marks the session for kill and ends it and rolls back all transactions that are associated with it as soon as possible. This operation can take a while.

system KILL altered.

Kill session imediatelly

You can force Oracle Database to kill session immediatelly:

alter system kill session 'sid,serial#' immediate

Result

Session is killed immediatelly:

system KILL altered.
Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
0
There are no comments. Click here to write the first comment.