日期:2014-05-16  浏览次数:20464 次

Oracle 数据库死锁问题

查看死锁的语句1:

select t2.username||'   '||t2.sid||'   '||t2.serial#||'   '||t2.logon_time||'   '||t3.sql_text
  from v$locked_object t1,v$session t2,v$sqltext t3
 where t1.session_id=t2.sid 
   and t2.sql_address=t3.address
 order by t2.logon_time ;

?语句2:

select a.object_name, b.* 
from all_objects a, 
     v$locked_object b
where a.object_id=b.object_id;

查看Session:

SELECT s.username,l.OBJECT_ID,l.SESSION_ID,s.SERIAL#,
l.ORACLE_USERNAME,l.OS_USER_NAME,l.PROCESS 
FROM V$LOCKED_OBJECT l,V$SESSION S WHERE l.SESSION_ID=S.SID;

?杀死Session,解锁:

alter system kill session 'sid,serial';

?此处的 sid, 即为[查看Session]中的 [SESSION_ID] 列, serial 为 [SERIAL#] 列, 杀完后, 完成.

?