Thursday, February 5, 2015

How to Kill the Oracle Session



Kill the Oracle Session
------------------------------
I was compiling one package it was running for long time.So i wanted to kill the session.


ALTER SYSTEM KILL SESSION 'SID,serial_number';


step 1 - using the below query you will get SID to be killed based on the package u can find th SID in the query result.

select ssession.sid, ssession.username, sql_text
from v$sqlarea sqlarea, v$session ssession
where ssession.sql_hash_value = sqlarea.hash_value
and   ssession.sql_address    = sqlarea.address
and   ssession.username is not null;

step2- with below query you will get serial number.

SELECT s.inst_id,
       s.sid,
       s.serial#,
       p.spid,
       s.username,
       s.program
FROM   gv$session s
       JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE  s.type != 'BACKGROUND'
and sid = 1111;

Step3 execute below command to kill the session.

sql>ALTER SYSTEM KILL SESSION '1054,10926';



No comments:

Post a Comment