oracle错误ORA-00054: resource busy and acquire with NOWAIT(转载)
Oracle杀死锁进程
先查看哪些表被锁住了:
1、获得sid
select b.owner,
?????? b.object_name,
?????? a.session_id,
?????? a.locked_mode from v$locked_object a,
?????? dba_objects b where b.object_id = a.object_id;
2、获得sid,serial
select b.username, b.sid, b.serial#, logon_time
? from v$locked_object a, v$session b
?where a.session_id = b.sid
?order by b.logon_time;
3、杀死锁进程
alter system kill session 'sid,serial';
如果有ora-00031错误,则在后面加immediate;
alter system kill session '29,5497' immediate;
--杀数据库进程(数据库服务器的机子)
SELECT a.username, c.spid AS os_process_id, c.pid AS oracle_process_id
?
FROM v$session a, v$process c
?WHERE c.addr = a.paddr
?? and a.sid ='1392'
?? and a.serial# ='10858';
?-----------------------------------------------
查找锁定的session
SELECT?? sn.username,m.SID,sn.SERIAL#, m.TYPE,??
??????? DECODE (m.lmode,??
??????????????? 0, 'None',??
??????????????? 1, 'Null',??
??????????????? 2, 'Row Share',??
??????????????? 3, 'Row Excl.',??
??????????????? 4, 'Share',??
??????????????? 5, 'S/Row Excl.',??
??????????????? 6, 'Exclusive',??
??????????????? lmode, LTRIM (TO_CHAR (lmode, '990'))??
?????????????? ) lmode,??
??????? DECODE (m.request,??
??????????????? 0, 'None',??
??????????????? 1, 'Null',??
??????????????? 2, 'Row Share',??
??????????????? 3, 'Row Excl.',??
??????????????? 4, 'Share',??
??????????????? 5, 'S/Row Excl.',??
??????????????? 6, 'Exclusive',??
??????????????? request, LTRIM (TO_CHAR (m.request, '990'))??
?????????????? ) request,??
??????? m.id1, m.id2??
??? FROM v$session sn, v$lock m??
?? WHERE (sn.SID = m.SID AND m.request !=0)??????? --存在锁请求,即被阻塞??
???? OR (??? sn.SID =m.SID??????????????????????? --不存在锁请求,但是锁定的对象被其他会话请求锁定??
???????? AND m.request = 0??
???????? AND lmode != 4??
???????? AND (id1, id2) IN (??
?????????????????????? SELECT s.id1, s.id2??
???????????????????????? FROM v$lock s??
??????????????????????? WHERE request != 0 AND s.id1 = m.id1??
????????????????????????????? AND s.id2 = m.id2)??
??????? )??
ORDER BY id1, id2, m.request;
?
通过数据字典V$SESSION与V$LOCK来了解正在等待锁资源的用户 ??