Oracle 10g 推出數據泵工具,提高數據遷移的效率,Oracle 10g剛推出的時候,跨版本的問題並不明顯,而等到11.2推出之後,數據泵同樣存在處理跨版本的問題。
Oracle原始的EXP/IMP導出、導入工具的跨版本特性對於從Oracle8、9版本就接觸數據庫的人來說,應該是基本常識了——低版本導出,目標版本導入。而對於數據泵來說,很多人並沒有意識到這一點,事實上數據泵如果從低版本導出,高版本導入是不需要額外處理的,而大多數的需求不是版本相同,就是版本升級,因此很多人沒有注意到數據泵的版本問題。
如果數據泵從高版本導出,低版本導入時,如果不加處理,就會出現下面的錯誤:
[oracle@rhlinux5 ~]$ expdp test/test directory=expdir dumpfile=test.dmp TABLES=tab1
Export: Release 11.2.0.3.0 - Production ON Mon Apr 27 09:50:10 2013
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 - 64bit Production
WITH the Partitioning, OLAP, DATA Mining AND REAL Application Testing options
Starting "TEST"."SYS_EXPORT_TABLE_01": test/******** dumpfile=test.dmp tables=tab1
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "TEST"."TAB1" 6.593 KB 63 rows
Master table "TEST"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
Dump file set for TEST.SYS_EXPORT_TABLE_01 is:
/u01/oracle/test.dmp
Job "TEST"."SYS_EXPORT_TABLE_01" successfully completed at 09:50:17
11.2導入的文件,10.2直接導入報錯:
[oracle@rhlinux5 ~]$ impdp test/test directory=expdir dumpfile=test.dmp
Import: Release 10.2.0.4.0 - 64bit Production ON Monday,27 April, 2013 9:50:25
Copyright (c) 2003, 2007, Oracle. ALL rights reserved.
Connected TO: Oracle DATABASE 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
WITH the Partitioning, 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/oracle/test.dmp"
正確的方式是在高版本導出的時候指定導出的版本,比如導入版本為10204,那麼在11.2上導出時通過VERSION=10.2.0.4,確保導出的數據和結構和低版本兼容。
[oracle@rhlinux5 ~]$ expdp test/test dumpfile=test.dmp directory=expdir TABLES=tab1 version=10.2.0.4
Export: Release 11.2.0.3.0 - Production ON Mon Apr 27 09:52:03 2013
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 - 64bit Production
WITH the Partitioning, OLAP, DATA Mining AND REAL Application Testing options
Starting "TEST"."SYS_EXPORT_TABLE_01": test/******** dumpfile=d_tmp:tab110204.dp tables=tab1 version=10.2.0.4.0
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "TEST"."TAB1" 6.406 KB 63 rows
Master table "TEST"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
Dump file set for TEST.SYS_EXPORT_TABLE_01 is:
/u01/oracle/test.dmp
Job "TEST"."SYS_EXPORT_TABLE_01" successfully completed at 09:52:09
這樣在10.2.0.4.0數據庫上就可以直接導入了。
[oracle@rhlinux5 ~]$ impdp test/test directory=expdir dumpfile=test.dmp
Import: Release 10.2.0.4.0 - 64bit Production ON Monday, 27 April, 2013 9:54:35
Copyright (c) 2003, 2007, Oracle. ALL rights reserved.
Connected TO: Oracle DATABASE 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
WITH the Partitioning, OLAP, DATA Mining AND REAL Application Testing options
Master TABLE "TEST"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "TEST"."SYS_IMPORT_FULL_01": test/******** directory=expdir dumpfile=test.dmp
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "TEST"."TAB1" 6.406 KB 63 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "TEST"."SYS_IMPORT_FULL_01" successfully completed at 09:54:36