oracle查看被锁的表

2020/1/4 21:02:21

Category 软件技术 Tag oracle,锁表

--查看被锁的表

select p.spid,

       a.SERIAL#,

       c.object_name,

       b.session_id,

       b.oracle_username,

       b.os_user_name

  from v$process p, v$session a, v$locked_object b, all_objects c

 where p.addr = a.paddr

   and a.process = b.process

   and c.object_id = b.object_id;

   

   --查询锁表原因

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#;


查看锁表进程SQL语句2: 

select * from v$session t1, v$locked_object t2 where t1.sid = t2.SESSION_ID; 



--解决办法

alter system kill session '2888,44';  --即spid,serial