Home > Database > Mysql Tutorial > body text

oracle 杀死死锁的方法

WBOY
Release: 2016-06-07 15:36:33
Original
1225 people have browsed it

执行以下语句,查看死锁: select /* rule */ lpad(' ',decode(l.xidusn,0,3,0))||l.oracle_username User_name, o.owner,o.object_name,o.object_type,s.sid,s.serial#,p.spid from v$locked_object l,dba_objects o,v$session s,v$process p where l.objec

执行以下语句,查看死锁:

select /* + rule */ lpad(' ',decode(l.xidusn,0,3,0))||l.oracle_username User_name,

o.owner,o.object_name,o.object_type,s.sid,s.serial#,p.spid
from v$locked_object l,dba_objects o,v$session s,v$process p 
where l.object_id=o.object_id
and l.session_id=s.sid
and s.paddr = p.addr 

order by o.object_id,xidusn DESC;

(执行这个语句的目的,是为了找到你需要杀死的死锁的SID和SERIAL#,注意:不建议你杀死别人的死锁,有可能别人在你查询死锁的时刻,正在做某些操作而锁表,刚好你正在查询死锁,其实你再查询的时候别人的锁已经解了。所以,无关自己的表的锁,不建议去杀死。)

好了,找到你需要操作的表名,然后找到对应的SID和SERIAL#

替换下面语句的变量,然后执行,即可解锁。

alter system kill session 'sid,serial#';

假如,你找到的SID和SERIAL#分别是:35,1980

那么你应该执行的杀死死锁的语句如下:

alter system kill session '35,1980';


然后再执行第一个语句看看你的死锁被杀死了没有?

肯定会成功的!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template