oracle锁的处理查找,处理

前端之家收集整理的这篇文章主要介绍了oracle锁的处理查找,处理前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一)锁相关的表

1)相关表
SELECT * FROM v$lock;
SELECT * FROM v$sqlarea;
SELECT * FROM v$session;
SELECT * FROM v$process ;
SELECT * FROM v$locked_object;
SELECT * FROM all_objects;
SELECT * FROM v$session_wait;

2)查看被锁的表
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;

--查看那个用户那个进程照成死锁
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;

--查看连接的进程
SELECT sid,serial#,username,osuser FROM v$session;

二)处理(杀死)锁

1)查找锁定表的sid,os_user_name,machine_name,terminal,锁的type,mode

SELECT s.sid,s.serial#,s.username,s.schemaname,s.osuser,s.process,s.machine,
s.terminal,s.logon_time,l.type
FROM v$session s,v$lock l
WHERE s.sid = l.sid
AND s.username IS NOT NULL
ORDER BY sid;


2)根据上面查询语句结果sid,serial#,杀掉进程

alter system kill session'210,11562';

猜你在找的Oracle相关文章