oracle中查询被锁的表并释放session

查询sql:

SELECT  A.OWNER,
A.
OBJECT_NAME ,
B.XIDUSN,
B.XIDSLOT,
B.XIDSQN,
B.SESSION_ID,
B.ORACLE_USERNAME, 
B.OS_USER_NAME,
B.PROCESS, 
B.LOCKED_MODE, 
C.MACHINE,
C.STATUS,
C.SERVER,
C.SID,
C.SERIAL#,
C.PROGRAM
FROM  ALL_OBJECTS A,
V$LOCKED_OBJECT B,
SYS.GV_$SESSION C 
WHERE  ( A. OBJECT_ID   =  B. OBJECT_ID  )
AND  (B.PROCESS  =  C.PROCESS )
ORDER   BY   1 , 2  

释放session Sql:
alter  system  kill  session  ' sid, serial# '

alter  system  kill  session  ' 379, 21132 '
alter  system  kill  session  ' 374, 6938
1、查看数据库锁,诊断锁的来源及类型: 
  select object_id,session_id,locked_mode from v$locked_object; 
或者用以下命令: 
select b.owner,b.object_name,l.session_id,l.locked_mode 
from v$locked_object l, dba_objects b 
where b.object_id=l.object_id 

2、找出数据库的serial#,以备杀死: 
   select t2.username,t2.sid,t2.serial#,t2.logon_time 
from v$locked_object t1,v$session t2 
where t1.session_id=t2.sid order by t2.logon_time; 

3、杀死该session alter system kill session 'sid,serial#'

你可能感兴趣的:(oracle,C++,c,SQL Server,C#)