append提示與外來鍵還有ORA-12838

OmarChina發表於2007-10-12

今天看AskTom上一文。記錄下。

有外來鍵的時後。append提示就會忽略了。

[@more@]

SQL> create table t1(id int primary key);

Table created.

SQL> create table t2(id int references t1);

Table created.

SQL> create table t3(id int);

Table created.

SQL> insert into t1 select rownum from dual connect by rownum<=10;

10 rows created.

SQL> commit;

Commit complete.

SQL> insert /*+append*/ into t2 select * from t1;

10 rows created.

SQL> insert /*+append*/ into t3 select * from t1;

10 rows created.

SQL> select count(*) from t2;

COUNT(*)

----------

10

因為T2表上存在外來鍵,所以APPEND失效。

SQL> select count(*) from t3;

select count(*) from t3

*

ERROR at line 1:

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

t3表採用了append插入方式插入資料效果生效,不COMMIT就會報錯。

SQL> commit

Commit complete.

SQL> select count(*) from t3;

COUNT(*)

----------

10

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9925929/viewspace-976090/,如需轉載,請註明出處,否則將追究法律責任。

相關文章