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 'sid,serial#';spid 锁住的进程号serial# v$session 这个视图中取出来的