Oracle查询被锁的表以及解锁表
程序员文章站
2022-06-11 19:26:58
...
1.查询引起了锁表的原因
select l.session_id sid,
s.serial#,
l.locked_mode,
l.oracle_username,
s.user#,
l.os_user_name,
s.machine,
s.terminal,
a.sql_text,
a.action
from v$sqlarea a, v$session s, v$locked_object l
where l.session_id = s.sid
and s.prev_sql_addr = a.address
order by sid, s.serial#;
2.查询被锁的表
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
3.查看是哪个session引起的
select b.username,b.sid,b.serial#,logon_time from v$locked_object a,v$session b where a.session_id = b.sid order by b.logon_time
4.杀掉对应进程即解锁
alter system kill session'135,397'
--其中135是sid 397是serial#
备注:该用户必须拥有DBA权限,否则提示找不到表和视图
上一篇: 面对紊乱的快照现象,你该如何“对症下药”
下一篇: 记一次测试开发面试