Resources / Blogs
Identifying Blocking Sessions in Oracle Database
Query to find out blocking sessions and the sessions that are getting blocked by these blockers.

Below SQL gives the blocker and blockee sessions in database.
Oracle RAC Environment:
select(select username from gv$session where sid=a.sid) blocker,a.sid,'is blocking',(select username from gv$session where sid=b.sid) blockee,b.sidfrom gv$lock a, gv$lock bwhere a.block > 0and b.request > 0and a.id1=b.id1and a.id2=b.id2;
Oracle Non-RAC Environment:
select(select username from v$session where sid=a.sid) blocker,a.sid,'is blocking',(select username from v$session where sid=b.sid) blockee,b.sidfrom v$lock a, v$lock bwhere a.block > 0and b.request > 0and a.id1=b.id1and a.id2=b.id2;


