oracle死锁查询和解决

首先查询死锁:
select sess.sid ||','||   
    sess.serial#,  
    lo.oracle_username,   
    lo.os_user_name,   
    ao.object_name,   
    lo.locked_mode,  
        SESS.machine  
    from v$locked_object lo,   
    dba_objects ao,   
    v$session sess   
where ao.object_id = lo.object_id and lo.session_id = sess.sid ;  

然后清除死锁程序:
 --kill该事务 例子 sid为339,serial#为13545
 alter system kill session '339,13545';


-- 查询有锁的sid
select t2.username,t2.sid,t2.serial#,t2.logon_time
from v$locked_object t1,v$session t2
where t1.session_id=t2.sid order by t2.logon_time;

-- 替换什么的sid查询具有sql  例子sid为2149
select sql_text from v$session a,v$sqltext_with_newlines b
 where DECODE(a.sql_hash_value, 0, prev_hash_value, sql_hash_value)=b.hash_value
 and a.sid=2149 order by piece;
 

你可能感兴趣的:(Oracle)