11G 新特性: 新加的提示IGNORE_ROW_ON_DUPKEY_INDEX
11G 新特性: 新加的提示IGNORE_ROW_ON_DUPKEY_INDEX
Kevin Zou
2012-3-28
在做INSERT INTO TARGET...SELECT...FROM SOURCE 操作時,遇到原先TARGET 中已有的記錄因違反唯一鍵而插入失敗。 新加的提示IGNORE_ROW_ON_DUPKEY_INDEX 就可以完全避免這種問題。
例子:
SQL> create table test as select * from dba_objects where object_id < 1000;
Table created.
SQL> select count(*) from test;
COUNT(*)
----------
942
SQL> alter table test add primary key (object_id);
Table altered.
SQL> delete test where object_id <> 999;
941 rows deleted.
SQL> commit;
Commit complete.
SQL> select count(*) from test;
COUNT(*)
----------
1
SQL> insert into test select * from dba_objects where object_id < 1000;
insert into test select * from dba_objects where object_id < 1000
*
ERROR at line 1:
ORA-00001: unique constraint (SYS.SYS_C0065959) violated
SQL> select count(*) from test;
COUNT(*)
----------
1
SQL> insert /*+ IGNORE_ROW_ON_DUPKEY_INDEX(test(object_id)) */ into test select
* from dba_objects where object_id < 1000;
941 rows created.
SQL> select count(*) from test;
COUNT(*)
----------
942
如果不加上這個HINT,那就需要用PL/SQL程式設計來實現;
SQL> rollback;
Rollback complete.
SQL> insert into test select a.* from dba_objects a, test b where a.object_id
< 1000 and a.object_id <> b.object_id;
941 rows created.
-THE END-
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/40239/viewspace-719747/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 11G 新特性: 新加的提示 CHANGE_DUPKEY_ERROR_INDEXErrorIndex
- Oracle11.2新特性之INSERT提示IGNORE_ROW_ON_DUPKEY_INDEXOracleIndex
- 【ORACLE新特性】11G 分割槽新特性Oracle
- oracle 11g 的新特性Oracle
- Oracle 11g 新特性Oracle
- 11g data guard 新特性
- 11g新特性--active dataguard
- 11G新特性:FLASHBACK ARCHIVEHive
- 11g新特性:Pending Statistics
- Oracle 11g 新特性簡介Oracle
- Oracle 11g 新特性之DRCPOracle
- 11g 新特性—— Active Database DuplicationDatabase
- Oracle 11g新特性:Result CacheOracle
- 11g新特性--result caching
- Oracle 11g 新特性(轉載)Oracle
- 11G新特性:FLASHBACK ARCHIVE - 01Hive
- 11G新特性:FLASHBACK ARCHIVE – 02Hive
- Oracle 11g新特性之SecureFilesOracle
- 11g新特性:不可視索引索引
- 11g新特性--pending statistics
- 11G新特性,待定的統計資訊
- 11G Flashback Data Archive新特性的研究Hive
- oracle DG 11g新特性彙總Oracle
- ORACLE 11G新特性之列新增操作Oracle
- 【11g新特性】(I/O calibration)
- Oracle 11g 新特性 -- SecureFiles 說明Oracle
- 11g新特性--invisible indexIndex
- oracle 11g 新特性 表壓縮Oracle
- 【DataGuard】11g 新特性:Active Data Guard
- goldengate 11g patch set 1的新特性Go
- Oracle 11g的新特性分割槽:System PartitionOracle
- Oracle 11g 新特性 -- SQL Plan Management 示例OracleSQL
- 11g叢集新特性-scan機制
- 11g新特性--自動儲存管理
- 11G 新特性:密碼大小寫策略密碼
- 11g 新特性—— Active Database Duplication for A standby databaseDatabase
- 天天學習ORACLE(三)-11G新特性Oracle
- 11G新特性,比較統計資訊