方法1:
1、当前session中commit、rollback都可以解锁
2、在别的session中(DBA)通过
查找用户锁
select s.username,
decode(l.type,'TM','TABLE LOCK',
'TX','ROW LOCK',
NULL) LOCK_LEVEL,
o.owner,o.object_name,o.object_type,
s.sid,s.serial#,s.terminal,s.machine,s.program,s.osuser
from v$session s,v$lock l,dba_objects o
where s.sid=l.sid
and o.object_id=l.id1
and s.username is not null
检查出来谁锁了该表
查看结果中object_name='你的表名'
然后得到sid,serial#
alter system kill session 'sid, serial#'
or
alter system disconnect session 'sid, serial#' immediate;
3、select * from table for update nowait可以指定nowait
执行后结果: 提示标记要删去的会话 无法释放会话,未成功解锁
方法2:
a、 找到你要杀掉的那个SESSION, 并记下paddr
SELECT sid, username, paddr, status FROM v$session WHERE username = '用户名' ; example:SELECT sid, username, paddr, status FROM v$session WHERE username = 'XNJW0419' ; SID USERNAME PADDR STATUS---------- ------------------------------ -------- -------- 10 XNJW0419 2B5E2E2C KILLED
b、 找到这个SESSION所对应的spid
SELECT * FROM v$process WHERE addr = '上面查寻的paddr'; example:SELECT ADDR,PID,SPID,USERNAME,SERIAL#,TERMINAL FROM v$process WHERE addr = '2B5E2E2C';ADDR PID SPID USERNAME SERIAL# TERMINAL-------- ---------- ------------ --------------- ---------- ----------------2B5E2E2C 44 1204 SYSTEM -99 JWC
c、 杀掉spid所标识的那个进程
D:/>orakill sid thread
sid = 数据库名
thread=SESSION所对应的spid
spid (注:cmd命令窗口中执行 只有oracle服务器端才有orakill命令)example: D:/>orakill oemrep 1204
提示:KILL OF THREAD id 1204 IN INSTANCE oemrep successfully signalled.
结果:成功删除该SESSION,表也解锁
本篇文章来源于:开发学院 http://edu.codepub.com 原文链接:http://edu.codepub.com/2010/0624/23746.php