1.查询引起了锁表的原因1
2
3
4
5
6
7
8
9
10
11
12
13
14select 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.查询被锁的表1
2
3
4
select distinct 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引起的1
2
3
4select 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.杀掉对应进程即解锁1
alter system kill session '135,39751'; --其中135是第3步中查询的sid, 39751是serial#。
备注:执行以上查询的数据库用户必须拥有DBA权限,否则提示找不到表和视图。