欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Oracle表被锁以及如何解锁的语句

程序员文章站 2022-06-11 19:24:24
...

1.查看表是否被锁定的语句

select a.object_name,b.session_id,c.serial#,c.program,
c.username,c.command,c.machine,c.lockwait 
from all_objects a,v$locked_object b,v$session c 
where a.object_id=b.object_id and c.sid=b.session_id;

2.查看被锁定的表的信息

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.解锁表


alter system kill session '19';#这里的19是session_id