Oralce 中查询锁表记录以及解锁
程序员文章站
2022-06-08 08:38:03
...
Oralce 中查询锁表记录以及解锁 先查询那些表被锁定了 select b.owner,b.object_name,a.session_id,a.locked_mode from v$locked
Oralce 中查询锁表记录以及解锁
先查询那些表被锁定了
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;
查询出被锁定的表的 sid 和serial# 然后kill
select b.username,b.sid,b.serial#,logon_time
from v$locked_object a,v$session b
where a.session_id = b.sid and sid in(
select a.SESSION_ID
from v$locked_object a,dba_objects b
where b.object_id = a.object_id) order by b.logon_time
解锁
alter system kill session '589,2693' immediate;(589 是sid,2693是serial)
另外作此操作的必须要有数据库管理的权限否则无法解锁。