oracle死锁笔记

查看oracle死锁

SELECT   s.username,
         decode(l.type, 'TM', 'TABLE LOCK', 'TX', 'ROW LOCK', NULL) LOCK_LEVEL,
         o.owner,
         o.object_name,
         o.object_type,
         s.sid,
         s.serial#
    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
    AND O.OWNER='NTJFW'--用户名

杀死进程:

alter system kill session 'sid,serial#';

 

查看死锁的sql

select sql_text from v$sql where hash_value in (select sql_hash_value 
from v$session where sid in  (select session_id from v$locked_object));  

 

你可能感兴趣的:(数据库)