DataPump關於跨數據庫版本remove數據

利用DATAPUMP來做不同版本數據庫之間的導入導出
在此做出聲明:從10g開始就有data pump工具,oracle保留了imp/exp工具,但做支持了(即對此工具不做更新操作);做數據的dump工作,建議用data pump
一、學習一下version這個參數在官方文檔裏的說明及解釋
version={compatible|lastest|version_string}三個value

二、利用DATAPUMP在不同數據庫版本之間操作的注意事項:
1、如果你從高版本往低版本導入,一些新特性將會無效。例如10.1沒有數據壓縮功能
2、在做export時,如果從高版本到低版本,生成的dump文件可以導入到低版本里,但是低版本不支持一些高版本的對象。從10.2.==>10.1上,索引類型的comments就不會被導出到dumpfile裏.
3、impdp能讀到低版本數據庫創建的dump文件
4、impdp不能做直接讀高版本的數據庫dump出來的dump文件,除非在做dump文件時,加了version參數去指定目標庫的版本號。因此,在做dump時,就是設置target庫的版本號
5、當通過network link來做dump時,datapump要求遠程數據庫的版本要與本地數據庫的版本一致或者比本地的低。例如:local database:10.2,則remote database必須是10.1or10.2(10GR2裏對此的解釋)。
      當通過network link來做dump時,數據泵要求源數據庫和目標數據庫相差不超過一個版本。例如:如果一個庫是oracle11g,那麼另個庫是11gor10g,並且只考察大版本號,不考慮小版本好(11gR2裏對此的解釋)

三、11g裏針對SecureFiles的注意事項
當你使用expdp dump SecureFiles LOBs時,由此產生的行爲取決於多方面,包括export的version參數,以及當前ContentType ,以及LOB的archived 和數據緩存。下列情況下將說明這些組合
1、 一個表包含SecureFiles LOBs with ContentType 和 VERSION參數設置的版本號是或低於11.2.0.0.0,那時ContentType不能被導出
2、一個表包含SecureFiles LOBs with ContentType 和 VERSION參數設置的版本號是或高於11.2.0.0.0,那時ContentType被導出和存放在subsequent導入
3、一個表包含SecureFiles LOBs 是 currently archived and the data is cached和 VERSION參數設置的版本號是或低於11.2.0.0.0,那時SecureFiles LOB data is exported and the archive metadata is dropped。在此場景下, 如果VERSION參數設置的版本號是或高於11.1.0.0.0,  SecureFiles LOB becomes a vanilla SecureFiles LOB. 但是如果VERSION參數設置的版本號是或低於於11.1.0.0.0, 那時SecureFiles LOB將變成BasicFiles LOB.
4、一個表包含SecureFiles LOBs 是 currently archived但是數據not cached和VERSION參數設置的版本號是或低於11.2.0.0.0,將會出現ORA-45001錯誤
5、一個表包含SecureFiles LOBs 是 currently archived and the data is cached和 VERSION參數設置的版本號是或高於11.2.0.0.0,cached data和the archive metadata被導出

建立測試環境:
1、建立data pump環境
SQL> create or replace directory dump_dir as '/u01/dump';
Directory created.
SQL> grant read,write on directory dump_dir to public;
Grant succeeded.
2、創建scott測試表test_pump

四、測試案例
高版本導出,低版本導入
1、export腳本
1)、不帶version參數
[oracle@ora11g dump]$ expdp scott/scott directory=dump_dir dumpfile=f.dmp logfile=impdp_f.log tables=test_pump;
Export: Release 11.2.0.3.0 - Production on Thu Jun 26 14:27:08 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_SCHEMA_01":  scott/******** directory=dump_dir dumpfile=f.dmp logfile=f.log schemas=scott
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 216.1 MB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . exported "SCOTT"."TEST_PUMP"                         181.5 MB 4587520 rows
. . exported "SCOTT"."DEPT"                              5.929 KB       4 rows
. . exported "SCOTT"."EMP"                               8.562 KB      14 rows
. . exported "SCOTT"."SALGRADE"                          5.859 KB       5 rows
. . exported "SCOTT"."BONUS"                                 0 KB       0 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
  /u01/dump/f.dmp
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 14:28:49
2)、帶version參數
[oracle@ora11g dump]$ expdp scott/scott directory=dump_dir dumpfile=f1.dmp logfile=impdp_f1.log tables=test_pump version=10.2.0.5.0;
Export: Release 11.2.0.3.0 - Production on Thu Jun 26 14:35:43 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SCOTT"."SYS_EXPORT_SCHEMA_01":  scott/******** directory=dump_dir dumpfile=f1.dmp logfile=f1.log schemas=scott versi
on=10.2.0.5.0
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 216.1 MB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
. . exported "SCOTT"."TEST_PUMP"                         181.5 MB 4587520 rows
. . exported "SCOTT"."DEPT"                              5.742 KB       4 rows
. . exported "SCOTT"."EMP"                               8.062 KB      14 rows
. . exported "SCOTT"."SALGRADE"                          5.671 KB       5 rows
. . exported "SCOTT"."BONUS"                                 0 KB       0 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
  /u01/dump/f1.dmp
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 14:36:32

2、import腳本
1)、當export時不帶version指定版本時,import時報錯ORA-39142
[oracle@trsen01 dump]$ impdp scott/scott directory=dump_dir dumpfile=f.dmp logfile=impdp_f.log tables=test_pump;
Import: Release 10.2.0.5.0 - Production on Thursday, 26 June, 2014 14:48:06
Copyright (c) 2003, 2007, Oracle.  All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
ORA-39001: invalid argument value
ORA-39000: bad dump file specification
ORA-39142: incompatible version number 3.1 in dump file "/u01/dump/f.dmp"

2)、當export時帶version指定版本號,導入時正常
[oracle@trsen01 dump]$ impdp scott/scott directory=dump_dir dumpfile=f1.dmp logfile=impdp_f.log tables=test_pump;
Import: Release 10.2.0.5.0 - Production on Thursday, 26 June, 2014 14:48:23
Copyright (c) 2003, 2007, Oracle.  All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
Master table "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01":  scott/******** directory=dump_dir dumpfile=f1.dmp logfile=impdp_f.log tables=test_pump
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."TEST_PUMP"                         181.5 MB 4587520 rows
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 14:49:57

五、測試結果

從實驗結果來看,確實像文檔所說的那樣,在做data pump的數據處理時,要注意跨數據庫版本的事項。





===========================
相關交流信息
QQ羣: 330218614
Email: [email protected]
Blog: http://blog.csdn.net/trsenzhang
============================



發佈了59 篇原創文章 · 獲贊 1 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章