session1:
SQL> create table test (id number,name varchar(20));
SQL> select distinct sid from v$mystat;
SID
----------
62
SQL> alter session force parallel dml;
SQL> insert /* +parallel(4) */ into test select rownum,'aa'||rownum from dual connect by level < 10000;
session2:
SQL> select distinct sid from v$mystat;
SID
----------
60
SQL> insert into test t values(0,'aa1');
-----hang住了
session1:
SQL> commit; Commit complete.
SQL> update /* +parallel(4) */ test set name='JJJJ' where id< 5000;
4999 rows updated.
session2:
SQL> insert into test t values(0,'aa1');
-----hang住了
SQL> select decode(request,0,'holder: ','waiter: ') ||
2 sid session_id,lmode, request, type
3 from v$lock
4 where (id1, id2, type) in (select id1, id2, type from v$lock where request > 0)
5 order by request;
SESSION_ID LMODE REQUEST TY
---------- ----- -------- --
holder: 62 6 0 TM
waiter: 60 0 3 TM
请问并行更新或插入会锁全表嘛?什么原理?