分类:
2012-08-12 23:45:44
一、查看有哪些表被锁住
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;
杀进程中的会话
alter system kill session 'sid,serial#';e.galter system kill session '29,5497';
如果有ora-00031错误,则在后面加immediate;
alter system kill session '29,5497' immediate;
二、如何杀死oracle死锁进程
1.查哪个过程被锁:
查V$DB_OBJECT_CACHE视图:
SELECT * FROM V$DB_OBJECT_CACHE A WHERE A.OWNER='GSEOPROD' AND A.LOCKS != '0';
2. 查是哪一个SID,通过SID可知道是哪个SESSION:
查V$ACCESS视图:
SELECT * FROM V$ACCESS WHERE OWNER='过程的所属用户' AND NAME='刚才查到的过程名';
3. 查出SID和SERIAL#:
查V$SESSION视图:
SELECT SID,SERIAL#,PADDR FROM V$SESSION WHERE SID='刚才查到的SID';
查V$PROCESS视图:
SELECT SPID FROM V$PROCESS WHERE ADDR='刚才查到的PADDR';
4. 杀进程:
(1)先杀ORACLE进程:
ALTER SYSTEM KILL SESSION '查出的SID,查出的SERIAL#';
(2)再杀操作系统进程:
KILL -9 刚才查出的SPID或ORAKILL 刚才查出的SID 刚才查出的SPID。