Home  >  Article  >  Database  >  Oralce 中查询锁表记录以及解锁

Oralce 中查询锁表记录以及解锁

WBOY
WBOYOriginal
2016-06-07 17:27:27958browse

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)

另外作此操作的必须要有数据库管理的权限否则无法解锁。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn