sqlplus "/as sysdba" (sys/change_on_install)
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;
alter system kill session ‘sid,serial#’; (其中sid=l.session_id)
select pro.spid from v$session ses,v$process pro where ses.sid=XX and ses.paddr=pro.addr;
其中sid用死锁的sid替换: exit
ps -ef|grep spid
其中spid是这个进程的进程号,kill掉这个Oracle进程
KILL -9 “刚才查出的SPID”
在WINDOWS平台,可以是偶那个orakill。
select A.SQL_TEXT, B.USERNAME, C.OBJECT_ID, C.SESSION_ID,
B.SERIAL#, C.ORACLE_USERNAME,C.OS_USER_NAME,C.Process,
''''||C.Session_ID||','||B.SERIAL#||''''
from v$sql A, v$session B, v$locked_object C
where A.HASH_VALUE = B.SQL_HASH_VALUE and
B.SID = C.Session_ID
--1、查找被锁表的object_id
select object_id from all_objects where object_name = upper('table_name') and object_type = 'TABLE'
--2、根据第1步查到的object_id查找被锁对象的会话ID
select session_id from v$locked_object where object_id = 1779474
--3、根据第2步查到的session_id查找serial#
select sid,serial# from v$session where sid = 284
--4、根据session_id和serial#杀掉进程
alter system kill session 'sid,serial#'
--查找在被锁对象上的操作语句
select sql_text from v$sqlarea where address = '00' --address为v$session中的sql_address字段