Oracle – Query locking

Display locks in Oracle database

select * from gv$lock where block = 1

select * from gv$session where sid in (1998)

select sid, serial#, lockwait,
blocking_instance, blocking_session,
final_blocking_instance, final_blocking_session
from gv$session where program not like 'oracle%'
and blocking_session is not null

--ALTER SYSTEM KILL SESSION 'sid,serial#,inst_id';

select * from gv$session where status = 'KILLED'

-- non-RAC environment
SELECT Decode(request, 0, 'Holder: ',
  'Waiter: ')
  ||vl.sid sess,
  status,id1,id2,lmode,request,vl.TYPE
FROM v$lock vl,v$session vs
WHERE ( id1, id2, vl.TYPE ) IN 
(SELECT id1, id2, TYPE FROM v$lock
  WHERE request > 0)
  AND vl.sid = vs.sid
ORDER BY id1, request

[Look for UBABLK in gv$transaction – if value remains static for a while, the transaction is potentially blocked

select * from gv$transaction

Leave a Reply

Your email address will not be published. Required fields are marked *