Friday, May 21, 2010

Identify long running session and kill it

Sometimes you can find an Oracle database session that has been running for very long time. You can find it with this query:
select s.username,s.sid,s.serial#,s.last_call_et/60 mins_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 last_call_et> 60
order
by sid,serial#,q.piece
Then you can kill it with (change sid and serial# using result from query above):
ALTER SYSTEM KILL SESSION 'sid,serial#';

No comments: