使用以下的脚本对于诊断锁有一定的帮助,但是还是不能找出罪魁祸首,有更好的方法,请大侠指点
description:display the blocker and waiter,and then display the blocker's current execute statement.
SELECT distinct s.sid,
s.serial#,
s.username,
decode(l.type, 'TM', 'TABLE LOCK', 'TX', 'ROW LOCK', l.type) LOCK_LEVEL,
o.object_name,
l.request,
l.lmode
FROM v$session s, v$lock l, dba_objects o
WHERE l.sid = s.sid
AND l.id1 = o.object_id(+)
AND s.username is NOT NULL;
select s.sid, s.serial#, s.username, t.sql_text
from v$session s, v$lock l, v$sqltext t
where s.sid = l.sid
and s.prev_hash_value = t.hash_value
and l.request = 0
and l.id1 in
(select distinct id1
from v$lock
where kaddr in
(select lockwait
from v$session s
where s.lockwait is not null));
阅读(605) | 评论(0) | 转发(0) |