← Sessions & Locks
Oracle · Sessions & Locks
How to check blocking and blocked sessions in Oracle
Find which Oracle sessions are blocking others, what they are waiting on, and the SQL involved.
Tested on11g12c18c19c21c23ai26ai
Show blocker → blocked pairs from V$SESSION. BLOCKING_SESSION is populated when a session is waiting on a lock held by another session; join it back to V$SESSION to see the whole picture.
SELECT b.sid AS blocker_sid, b.serial# AS blocker_serial, b.username AS blocker_user,
b.machine AS blocker_machine, b.program AS blocker_program,
w.sid AS blocked_sid, w.serial# AS blocked_serial, w.username AS blocked_user,
w.event AS blocked_wait_event, w.seconds_in_wait AS wait_sec,
w.sql_id AS blocked_sql_id
FROM v$session w
JOIN v$session b ON b.sid = w.blocking_session
WHERE w.blocking_session IS NOT NULL
ORDER BY w.seconds_in_wait DESC;locksblockingv$session