ITeye博客

Oracle发现所有用户锁 和锁等待或死锁

wxpwdm8461 · 2009-07-20 22:29 · ORACLE学习笔记 · Oracle · Markdown

如果仅仅是lock,以下语句可以发现所有用户锁  
  select   s.username,  
  decode(l.type,'TM','TABLE   LOCK',  
                              'TX','ROW   LOCK',  
                              NULL)   LOCK_LEVEL,  
  o.owner,o.object_name,o.object_type,s.terminal,s.machine,s.program,s.osuser  
  from   v$session   s,v$lock   l,dba_objects   o  
  where   s.sid=l.sid  
  and   o.object_id=l.id1  
  and   s.username   is   not   null  
   
  如果有锁等待或死锁,可以通过以下语句发现  
  select   lpad('   ',decode(l.xidusn,0,3,0))||l.oracle_username   User_name,  
                o.owner,o.object_name,o.object_type  
  from   v$locked_object   l,dba_objects   o  
  where   l.object_id=o.object_id  
  order   by   o.object_id   desc

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。