1. ORACLE中查看当前系统中锁表情况
select * from v$locked_object
可以通过查询v$locked_object拿到sid和objectid,然后用sid和v$session链表查询是哪里锁的表,用v$session中的objectid字段和dba_objects的id字段关联,查询详细的锁表情况。
查询SQL如下:
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, v$process p
where ao.object_id = lo.object_id
and lo.session_id = sess.sid;
查询是什么SQL引起了锁表的原因,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#;
2. ORACLE解锁的方法
alter system kill session ’146′; –146为锁住的进程号,即spid
欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://p.delit.cn/) | Powered by Discuz! X3.2 |