Sunday, August 30, 2020

Kill Session in Oracle

Launch SQLPlus:

[oracle@localhost ~]$ sqlplus
Enter user-name: hr

Enter password: 

EXEC HI -- HI is long running stored procedure

Connect to Oracle as DBA and replace HR with you user

sqlplus sys as sysdba

select sid, serial#, status, program from v$session where username='HR';

ALTER SYSTEM KILL SESSION 'sid, serial#';

In SQL Developer:

select s.username,s.sid,s.serial#,s.last_call_et running,q.sql_text from v$session s 
join v$sqltext_with_newlines q
on s.sql_address = q.address
where status='ACTIVE'
and type <>'BACKGROUND'
and s.username = 'HR'
order by sid,serial#,q.piece;