SELECT A.OBJECT_NAME, A.STATUS, V.SESSION_ID FROM ALL_OBJECTS A, V$LOCKED_OBJECT V WHERE A.OBJECT_ID = V.OBJECT_ID AND A.OBJECT_NAME LIKE '表名';
你在一个进程里update这条记录——这个进程将处于等待状态, 然后你另开连接,执行以下语句--查等待进程 select * from gv$lock where request > 0 ;--查持有锁进程 select a.inst_id, a.sid, b.ctime,b.id1, a.sql_id, 'alter system kill session ''' || a.sid || ',' || serial# || ''';' kill, a.*, b.* from gv$session a, gv$lock b where a.inst_id = b.inst_id and a.sid = b.sid and b.id1 in (select id1 from gv$lock where request > 0) and b.lmode > 0 order by a.inst_id, a.sid;
你要先COMMINT
FROM ALL_OBJECTS A, V$LOCKED_OBJECT V
WHERE A.OBJECT_ID = V.OBJECT_ID
AND A.OBJECT_NAME LIKE '表名';
然后你另开连接,执行以下语句--查等待进程
select * from gv$lock where request > 0 ;--查持有锁进程
select a.inst_id, a.sid, b.ctime,b.id1, a.sql_id,
'alter system kill session ''' || a.sid || ',' || serial# || ''';' kill,
a.*, b.*
from gv$session a, gv$lock b
where a.inst_id = b.inst_id
and a.sid = b.sid
and b.id1 in (select id1 from gv$lock where request > 0)
and b.lmode > 0
order by a.inst_id, a.sid;