Monday, October 01, 2012

Useful Oracle Queries

The following query shows the last sql text from an inactive session


select sess.sid,
       sess.serial#,
       sess.username,
       sql_text
 from v$sqlarea sqlarea, v$session sess
 where sess.prev_hash_value = sqlarea.hash_value
   and sess.prev_sql_addr  = sqlarea.address
   and sess.username is not null
   and sess.status='INACTIVE';   


The following query shows which session (id) is blocking which session (id)

select blocking_session, sid, serial#, wait_class, seconds_in_wait from v$session where blocking_session is not NULL order by blocking_session;
And this is a very relevant post to the topic



No comments: