Thursday, January 17, 2008

Oracle : How to query row locking in oracle database

issue this sql command to see there are locking rows or object in your oracle database

set lines 160
col object_name for a20
col terminal for a20
col username for a20
col sid_serial for a20 justify left
select /* + rule */ a.inst_id, b.object_name, '''' || c.sid || ',' || c.serial# || '''' sid_serial, c.username,c.terminal, c.sql_hash_value, c.last_call_et,
decode(a.locked_mode,
0,'None',
1,'Null',
2,'Row Share',
3,'Row Excl.',
4,'Share',
5,'S/Row Excl.',
6,'Exclusive') lock_mode
from gv$locked_object a,
dba_objects b,
gv$session c
where a.object_id = b.object_id
and a.session_id = c.sid
and a.inst_id = c.inst_id
order by 7 desc
/

No comments: