come from itpub:
一个session对一个表进行append方式insert时,另一个session也对该表进行写操作,居然挂起。。。。。。这样岂不是并发时刻,会造成等待的出现?
direct insert需要TM 6锁,而普通的insert只需要TM 3锁。
In direct-load INSERT, exclusive locks are obtained on the table (or on all
the partitions of a partitioned table) precluding any concurrent insert,
update, or delete on the table. Concurrent queries, however, are supported and
will see only the data in the table before the INSERT began. These locks also
prevent any concurrent index creation or rebuild operations. This must be taken
into account before using direct-load INSERT because it affects table
concurrency.
append操作会在表上持有一个排他锁,其它用户无法DML操作,等待事件是enqueue.
测试:
conn test/test
session 1:
SQL> insert /*+append*/ into t
2 select * from all_objects;
已创建42913行。
session 1:
SQL> insert /*+append*/ into t
2 select * from all_objects;
insert /*+append*/ into t
*
第 1 行出现错误:
ORA-12838: 无法在并行模式下修改之后读/修改对象
(如果多个带有append的insert ,一定要先commit;然后再执行下一条,不然会提示
ORA-12838: cannot read/modify an object after modifying it in parallel)
session 2:
conn test/test
SQL> insert /*+append*/ into t
2 select * from all_objects;
session 2会话挂起。
session 3
conn test/test
SQL> @ D:oracleproduct10.1.0db_1rdbmsadminutllockt
WAITING_SESSION LOCK_TYPE MODE_REQUESTED MODE_HELD LOCK_ID1 LOCK_ID2
----------------- ----------------- -------------- -------------- ----------------- -----------------
162 None
137 DML Exclusive Exclusive 44447 0
SQL> select * from v$lock;
ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME
-------- -------- ---------- -- ---------- ---------- ---------- ---------- ---------- --
2E034248 2E034260 137 TM 44447 0 0 6 83
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9599/viewspace-472977/ ,如需转载,请注明出处,否则将追究法律责任。