描述:insert产生阻塞。
1,建立测试表。
SQL> create table lock1 (id1 int primary key);
Table created.
2,打开2个会话顺序执行插入操作,不提交.
会话15:
SQL> select sid from v$mystat where rownum<2;
SID
----------
15
SQL> insert into lock1 values (1);
1 row created.
会话151:
SQL> select sid from v$mystat where rownum<2;
SID
----------
151
SQL> insert into lock1 values (1); 《====会话151 插入数据库,产生阻塞事件。
3,查看等待
SQL> select sid,event,BLOCKING_SESSION from v$session where BLOCKING_SESSION is not null;
SID EVENT BLOCKING_SESSION
---------- ---------------------------------------------------------------- ----------------
151
enq: TX - row lock contention 15 《================151 被15 给阻塞了。产生enq: TX - row lock contention 等待事件。
SQL> select * from v$Lock where sid in (15,151,21) and type='TX' order by sid;
ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
55C69924 55C69964 15 TX 393230 952 6 0 165 1《===========waiting on a ROW。
55C7B03C 55C7B07C 151 TX 524320 892 6 0 104 0
576F9504 576F9530 151 TX 393230 952 0 4 104 0《=============== waiting some other resource held。
by the TX
0 - none
1 - null (NULL)
2 - row-S (SS)
3 - row-X (SX)
4 - share (S)
5 - S/Row-X (SSX)
6 - exclusive (X)
=================
网页名称:insert产生阻塞
标题来源:
http://jkwzsj.com/article/gchggg.html