Oacle 잠 금 조회

3415 단어 Oacle
        ,          , Oracle                        :
Sql  

select t2.username,  
       t2.sid,  
       t2.serial#,  
       t3.object_name,  
       t2.OSUSER,  
       t2.MACHINE,  
       t2.PROGRAM,  
       t2.LOGON_TIME,  
       t2.COMMAND,  
       t2.LOCKWAIT,  
       t2.SADDR,  
       t2.PADDR,  
       t2.TADDR,  
       t2.SQL_ADDRESS,  
       t1.LOCKED_MODE  
  from v$locked_object t1, v$session t2, dba_objects t3  
where t1.session_id = t2.sid  
   and t1.object_id = t3.object_id  
order by t2.logon_time;  



        ,    SQL     Oracle         ,   v$locked_object、v$session、dba_objects:
     v$locked_object         session            。
     v$session        session     。
     dba_objects  oracle            ,                     。

     v$locked_object  LOCKED_MODE        ,oracle          :

     0:none 
    1:null   
    2:Row-S    (RS):    ,sub share  
    3:Row-X    (RX):      ,sub exclusive  
    4:Share    (S):    DML  ,share 
    5:S/Row-X      (SRX):        ,share/sub exclusive  
    6:exclusive   (X):      ,exclusive 

         ,        。 

1   :Select,    v$locked_object  。 
2   :Select for update,Lock For Update,Lock Row Share  
select for update     for update         ,                (Row-X)     ,             ,    update、delete select for update  。 
3   :Insert, Update, Delete, Lock Row Exclusive 
  commit                ,      3          3  ,                 。 
4   :Create Index, Lock Share 
locked_mode 2,3,4   DML(insert,delete,update,select)  ,  DDL(alter,drop )     ora-00054  。 
00054, 00000, "resource busy and acquire with NOWAIT specified" 
// *Cause: Resource interested is busy. 
// *Action: Retry if necessary. 
5   :Lock Share Row Exclusive  
           update / delete ... ;      4,5  。 
6   :Alter table, Drop table, Drop Index, Truncate table, Lock Exclusive 

            oracle      :

--  session      sql  ,                              .
SELECT /*+ ORDERED */ 
sql_text
  FROM v$sqltext a
WHERE (a.hash_value, a.address) IN
       (SELECT DECODE(sql_hash_value, 0, prev_hash_value, sql_hash_value),
               DECODE(sql_hash_value, 0, prev_sql_addr, sql_address)
          FROM v$session b
         WHERE b.sid = '233')  /*   233  SID*/
ORDER BY piece ASC;


--   .
select * from v$process ; 

--  
   select * from v$lock; 

--      
select * from v$locked_object

--   
select * from v$transaction 

-- session
select v.* from v$session v where machine='xxx' and username='xxx' and status='INACTIVE' order by last_call_et desc

-- dba_objects  
select * from dba_objects 
where object_id = '14977'

--     
select t2.username,t2.sid,t2.serial#,t3.object_name,t2.OSUSER,t2.MACHINE,t2.PROGRAM,t2.COMMAND,t2.LAST_CALL_ET
        from v$locked_object t1,v$session t2 ,dba_objects t3
        where t1.session_id=t2.sid  and t1.object_id = t3.object_id
        order by t2.logon_time;

좋은 웹페이지 즐겨찾기