日期:2014-05-17  浏览次数:21287 次

oracle10g,有一个表和一个存储过程被锁了,但在v$locked_object中找不到记录,请问如何解决?
oracle10g,有一个表和一个存储过程被锁了,但在v$locked_object中找不到记录,请问如何解决?

------解决方案--------------------
SQL code

SELECT p.spid,p.USERNAME as proname, s.USERNAME,s.STATUS,s.OSUSER,s.MACHINE, s.program,s.sid,s.PADDR,a.OBJECT
                 FROM v$process p, v$session s,V$ACCESS a
                 WHERE p.addr=s.paddr
                 and a.SID=s.SID
                 and a.TYPE = 'PROCEDURE' 
                 and s.OSUSER='Administrator'

 杀掉spid所标识的那个进程 

D:>orakill sid  spid (注:cmd命令窗口中执行 只有oracle服务器端才有orakill命令)
example: D:>orakill oemrep 1204

提示:KILL OF THREAD id 1204 IN INSTANCE oemrep successfully signalled.

结果:成功删除该SESSION,表也解锁

------解决方案--------------------
或者直接在v$session中查询 然后用ALTER SYSTEM KILL SESSION 'sid, serial#';去删除会话
------解决方案--------------------
SQL code
select /*+   rule   */
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  l.sid = s.sid
and    l.id1 = o.object_id(+)
and    s.username is not null;

------解决方案--------------------
要看是什么锁了,是ddl锁你找不到,dml锁才能用 v$locked_object找到 

可以试试: 
dba_dml_locks; 
dba_ddl_locks;