oracle 查看锁表sql语句(导致锁表的sql)、解锁语句
--查看锁表进程SQL语句1:
--被锁对象表、数据库对象表、数据session表关联来获取被锁对象对应的是那个session;
select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id = lo.object_id and lo.session_id = sess.sid;
--查看锁表进程SQL语句2:
select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID;
--查看导致锁表的sql语句是那一条
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#;
--杀掉锁表进程:
--通过上面的查询获取SID和serial#,替换下面的x,y,就可以解除被锁的状态
alter system kill session 'x,y';
推荐阅读