Oracle/Oh Oracle

Oracle Insert TX-Lock 발생

darkturtle26 2018. 4. 13. 18:08

Oracle Insert TX-Lock 발생 


링크  - https://uhesse.com/2017/11/27/why-insert-causes-tx-row-lock-contention-or-tm-contention-in-oracle/



## SESSION 1
TEST> create table check_lock ( a1 number, a2 varchar2(100));
Table created.
TEST> create unique index xuk_check_lock on check_lock ( a2 );
Index created.
TEST> insert into check_lock values ( 1, 'a');
1 row created.
TEST>
## SESSION 2
TEST> insert into check_lock values ( 1, 'a');
## MONITORING SESSION
TEST> select
2 (select username from v$session where sid=a.sid) blocker,
3 a.sid,
4 ' is blocking ',
5 (select username from v$session where sid=b.sid) blockee,
6 b.sid
7 from
8 v$lock a,
9 v$lock b
10 where
11 a.block = 1
12 and
13 b.request > 0
14 and
15 a.id1 = b.id1
16 and
17 a.id2 = b.id2;
BLOCKER SID 'ISBLOCKING' BLOCKEE SID
------------------------------ ---------- ------------- ------------------------------ ----------
SYS 42 is blocking SYS 34
TEST>