fbpx

How to Kill a Session in Oracle RAC Database

If you need to kill a session in Oracle RAC database then first you need to know the SID, Serial# and the instance where the session is running.

You can get that info depending on what you are given, let’s see some options.

If you know the SID, then you can get the other values with this query

select sid,serial#,inst_id 
from gv$session 
where sid='1195';

Now let’s suppose that you have the serial# then use this query

select sid,serial#,inst_id, sql_id 
from gv$session 
where serial#='15148';

In case you have the username, use this query, you could add the logon_time to the query

select sid,serial#,inst_id 
from gv$session 
where USERNAME='username';

Or maybe you are given the SQL_ID, then you can get the details with this query

select sid,serial#,inst_id 
from gv$session 
where SQL_ID='gryb9nc9udsgu';

Once you know the SID, serial# and instance ID then this is the command to kill the session

alter system kill session 'SID,serial#,@instance' IMMEDIATE;

Replace accordingly

alter system kill session '325,24996,@2' IMMEDIATE;

Then you can check again to see if the session is still shown in gv$session.

Leave a Reply

Your email address will not be published. Required fields are marked *