資料泵的跨版本問題

yangtingkun發表於2012-04-27

資料泵在10g剛推出的時候,跨版本的問題並不明顯,而等到11.2推出之後,資料泵同樣存在處理跨版本的問題。

 

 

Oracle原始的EXP/IMP匯出、匯入工具的擴版本特性對於從8/9版本就接觸資料庫的人來說,應該是基本常識了——低版本匯出,目標版本匯入。

而對於資料泵來說,很多人並沒有意識到這一點,事實上資料泵如果從低版本匯出,高版本匯入是不需要額外處理的,而大多數的需求不是版本相同,就是版本升級,因此很多人沒有注意到資料泵的版本問題。

不過如果資料泵從高版本匯入大低版本,如果不加處理,就會出現下面的錯誤:

[orat1@hpserver2 ~]$ expdp test/test dumpfile=d_tmp:tab1.dp tables=tab1

Export: Release 11.2.0.3.0 - Production on Mon Apr 27 09:50:10 2012

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:tab1.dp 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:
/tmp/tab1.dp
Job "TEST"."SYS_EXPORT_TABLE_01" successfully completed at 09:50:17

11.2匯入的檔案,10.2直接匯入報錯:

[orat3@hpserver2 ~]$ impdp test/test directory=d_tmp dumpfile=tab1.dp

Import: Release 10.2.0.4.0 - 64bit Production on Monday,27 April, 2012 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 "/tmp/tab1.dp"

正確的方式是在高版本匯出的時候指定匯出的版本,比如匯入版本為10204,那麼在11.2上匯出時透過VERSION=10.2.0.4,確保匯出的資料和結構和低版本相容。

[orat1@hpserver2 ~]$ expdp test/test dumpfile=d_tmp:tab110204.dp tables=tab1 version=10.2.0.4

Export: Release 11.2.0.3.0 - Production on Mon Apr 27 09:52:03 2012

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
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:
/tmp/tab110204.dp
Job "TEST"."SYS_EXPORT_TABLE_01" successfully completed at 09:52:09

這樣在10.2.0.4資料庫上就可以直接匯入了。

[orat3@hpserver2 ~]$ impdp test/test directory=d_tmp dumpfile=tab110204.dp

Import: Release 10.2.0.4.0 - 64bit Production on Monday, 27 April, 2012 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=d_tmp dumpfile=tab110204.dp
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

 

 

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

相關文章