oracle查看表锁及解锁
--kill session语句
1 |
alter system kill SESSION '2171,60490' ; |
--以下几个为相关表
1
2
3
4
5
6
7 |
SELECT * FROM v$lock; SELECT * FROM v$sqlarea; SELECT * FROM v$session; SELECT * FROM v$process ; SELECT * FROM v$locked_object; SELECT * FROM all_objects; SELECT * FROM v$session_wait; |
--1.查出锁定object的session的信息以及被锁定的object名
1
2
3
4
5
6 |
SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username, l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time FROM v$locked_object l, all_objects o, v$session s WHERE l.object_id = o.object_id AND l.session_id = s.sid ORDER BY sid, s.serial# ; |
--2.查出锁定表的session的sid, serial#,os_user_name, machine name, terminal和执行的语句
--比上面那段多出sql_text和action
1
2
3
4
5
6 |
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#; |
--3.查出锁定表的sid, serial#,os_user_name, machine_name, terminal,锁的type,mode
1
2
3
4
5
6 |
SELECT s.sid, s.serial#, s.username, s.schemaname, s.osuser, s.process, s.machine, s.terminal, s.logon_time, l.type FROM v$session s, v$lock l WHERE s.sid = l.sid AND s.username IS NOT NULL ORDER BY sid; |
--4.查看链接数
1 |
select count (*) from v$session; |
作者:九州浪子
出处:http://www.cnblogs.com/juforg/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。