|
使用本人写的脚本可以找出SESSION 之间的锁关系,速度很快哦
----***************************************--
set serveroutput on
declare
mes varchar2(2000);
tmp_id1 number(22);
tmp_id2 number(22);
lk_sid number(22);
tmp_mac varchar2(64);
fl boolean;
begin
fl:=false;
for c1 in (select sid,serial#,machine,lockwait
from v$session
where lockwait is not null) loop
fl:=true;
mes:='sid:'||to_char(c1.sid)||','||c1.machine||'is be locked by sid ';
select id1,id2 into tmp_id1,tmp_id2
from v$lock where sid=c1.sid and kaddr=c1.lockwait;
for c2 in (select sid lk_sid from v$lock where sid!=c1.sid and id1=tmp_id1 and id2=tmp_id2 and block='1') loop
select machine into tmp_mac from v$session where sid=c2.lk_sid;
dbms_output.put_line(mes||to_char(c2.lk_sid)||' '||tmp_mac);
end loop;
end loop;
if not fl then
dbms_output.put_line('目前系统中没有互锁现象');
end if;
end;
/
再使用以下脚本可以找出相应的Session最近在干什么(速度一般
-----**************************************************----
---当前SID的正在运行的SQL语句
set verify off
column a.username format a10
column c.sql_text format a64
accept sid prompt 'Please enter the sid '
select a.username, c.sql_text
from v$session a, v$sqltext c
where a.sid=&sid and
c.hash_value = a.sql_hash_value and
c.address = a.sql_address
order by c.PIECE
/ |
|