lock

会话1:

SQL> create table t(id int primary key);


Table created.


SQL> insert into t values(1);


1 row created.


SQL> commit;


Commit complete.


SQL> update t set id=2 where id=1;


1 row updated.


会话2:(当会话2去更新数据时,会出现等待)

SQL> update t set id=3 where id=1;


会话3:(会话3去查询lock)

SQL> select SID,TYPE,ID1,ID2,LMODE,REQUEST,BLOCK from v$lock where type in('TX','TM') order by 1,2;


       SID TY        ID1        ID2      LMODE    REQUEST      BLOCK

---------- -- ---------- ---------- ---------- ---------- ----------

        47 TM      87554          0          3          0          0

        47 TX     655387        933          0          6          0

        48 TM      87554          0          3          0          0

        48 TX     655387        933          6          0          1


SQL> select object_name from dba_objects where object_id=87554;


OBJECT_NAME

--------------------------------------------------------------------------------

T


SQL> select sid,EVENT from v$session_wait where sid in(48,47);


       SID EVENT

---------- ----------------------------------------------------------------

        47 enq: TX - row lock contention

        48 SQL*Net message from client


你可能感兴趣的:(oracle-lock)