Select '节点 ' || a.INST_ID || ' session ' || a.sid || ',' || a_s.SERIAL# ||
' 阻塞了 节点 ' || b.INST_ID || ' session ' || b.SID || ',' || b_s.SERIAL# blockinfo,
a.INST_ID,
a_s.SID,
a_s.SCHEMANAME,
a_s.MODULE,
a_s.STATUS,
a.type lock_type,
a.id1,
a.id2,
decode(a.lmode,
0,
'none',
1,
null,
2,
'row-S (SS)',
3,
'row-X (SX)',
4,
'share (S)',
5,
'S/Row-X (SSX)',
6,
'exclusive (X)') lock_mode,
'后为被阻塞信息' ,
b.INST_ID blocked_inst_id,
b_s.SID blocked_sid,
b.TYPE blocked_lock_type,
decode(b.request,
0,
'none',
1,
null,
2,
'row-S (SS)',
3,
'row-X (SX)',
4,
'share (S)',
5,
'S/Row-X (SSX)',
6,
'exclusive (X)') blocked_lock_request,
b_s.SCHEMANAME blocked_SCHEMANAME,
b_s.MODULE blocked_module,
b_s.STATUS blocked_status,
b_s.SQL_ID blocked_sql_id,
obj.owner blocked_owner,
obj.object_name blocked_object_name,
obj.OBJECT_TYPE blocked_OBJECT_TYPE,
case
when b_s.ROW_WAIT_OBJ# <> -1 then
dbms_rowid.rowid_create(1,
obj.DATA_OBJECT_ID,
b_s.ROW_WAIT_FILE#,
b_s.ROW_WAIT_BLOCK#,
b_s.ROW_WAIT_ROW#)
else
'-1'
end blocked_rowid, --被阻塞数据的rowid
decode(obj.object_type,
'TABLE',
'select * from ' || obj.owner || '.' || obj.object_name ||
' where rowid=''' ||
dbms_rowid.rowid_create(1,
obj.DATA_OBJECT_ID,
b_s.ROW_WAIT_FILE#,
b_s.ROW_WAIT_BLOCK#,
b_s.ROW_WAIT_ROW#) || '''',
NULL) blocked_data_querysql from gv$lock a,
gv$lock b,
gv$session a_s,
gv$session b_s,
dba_objects obj
where a.id1 = b.id1
and a.id2 = b.id2
and a.BLOCK > 0 --阻塞了其他人
and b.request > 0
and ((a.INST_ID = b.INST_ID and a.sid <> b.sid) or
(a.INST_ID <> b.INST_ID))
and a.sid = a_s.sid
and a.INST_ID = a_s.INST_ID
and b.sid = b_s.sid
and b.INST_ID = b_s.INST_ID
and b_s.ROW_WAIT_OBJ# = obj.object_id(+)
order by a.inst_id,a.sid
一条查询Oracle中的阻塞锁(以及阻塞在哪个数据上)的SQL
最新推荐文章于 2024-08-28 02:06:54 发布