oracle查看锁表

--查看被锁表
SELECT substr(v$lock.sid,1,4) "SID",
       substr(username,1,12) "UserName",
       substr(object_name,1,25) "ObjectName",
       v$lock.type "LockType",
       decode(rtrim(substr(lmode,1,4)),
       '2','Row-S (SS)','3','Row-X (SX)',
       '4','Share',     '5','S/Row-X (SSX)',
       '6','Exclusive', 'Other' ) "LockMode",
       substr(v$session.program,1,25) "ProgramName"
FROM V$LOCK,SYS.DBA_OBJECTS,V$SESSION
WHERE (OBJECT_ID = v$lock.id1
      AND v$lock.sid = v$session.sid
      AND username IS NOT NULL
      AND username NOT IN ('SYS','SYSTEM')
      AND SERIAL# != 1);
      
select * from v$locked_object;

--查看表级锁
SELECT /*+ rule*/ 
  a.sid, b.owner, object_name, object_type 
  FROM v$lock a, all_objects b 
  WHERE TYPE = 'TM' 
  and a.id1 = b.object_id;

--查看表级锁的sid 和  serial#
SELECT sid,serial# FROM v$session WHERE sid =518; 

--杀掉锁表进程
alter system kill session '518,64232'; 

你可能感兴趣的:(oracle,oracle,object,session,system,kill,null)