ORA-12838: cannot read/modify an object after modifying it in parallel

      今天濤神說程序報ORA-12838錯誤,調出程序sql發現是一個大批量的insert,裏面使用了

   /*+ append */的hint,於是下面做了段模擬這個錯誤實驗  


 session 1   

SQL> create table tb_test as select * from emp where 1=2;

Table created.

SQL> insert /*+ append */ into tb_test select * from emp;    

14 rows created.  -- 注意/*+ append*/ 沒有commit

SQL> select * from tb_test;
select * from tb_test
              *
ERROR at line 1:
ORA-12838: cannot read/modify an object after modifying it in parallel


 session 2

SQL> select * from tb_test;

no rows selected

session 1 報了ORA-12838的錯誤,session正常,說明了在同一個事物中如果使用/*+ append */ insert如果沒有commit去做dml操作會這個錯誤,


進一步查詢發現表上加了類型爲6的鎖

SQL> col object_name for a20;
SQL> select t2.object_name,t1.LOCKED_MODE from  v$locked_object t1 join dba_objects t2 on t1.OBJECT_ID = t2.object_id;

OBJECT_NAME	     LOCKED_MODE
-------------------- -----------
TB_TEST 		       6


我們知道 locked mode 6: Lock table t in exclusive mode, 排他鎖限制最高的TM鎖,會禁止執行任何類型的DML語句

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章