【ORA-02049】超时分布式事务处理等待锁

(1)以sys用户登陆数据库查询死锁:
SQL> select username,lockwait,status,machine,program from v$session where sid in
     (select session_id from v$locked_object);
 
(2)然后使用一下语句查找被死锁的语句
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));
 
(3)再使用以下语句查找被死锁的进程
SQL> 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;
 
(4)使用一下语句把死锁的进程kill
SQL>alter system kill session ‘sid,serial#’; (其中sid=l.session_id)
如:SQL> alter system kill session '24,37522';


-----------------------------------------------------------------------------------------------

杀掉Linux服务器上的Oracle处理进程

SELECT s.username,l.OBJECT_ID,l.SESSION_ID,s.SERIAL#, l.ORACLE_USERNAME,
       l.OS_USER_NAME,l.PROCESS, spid, osuser, s.program 
FROM V$LOCKED_OBJECT l,V$SESSION S, v$process p
WHERE l.SESSION_ID=S.SID  and s.paddr = p.addr;


kill -9 spid

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