Thursday, May 21, 2015

Export/Import between different releases of Oracle


Question:  I am trying to take a 10g export file and import it into Oracle 11g.
How do I use the Oracle11g Data Pump impdp import with a dmp file that was created from Oracle 10g?

Answer:  While there is never a guarantee that an later release expdp dmp file will import into an earlier release of Oracle (this is called “forward compatibility”, impossible because Oracle can never know about future enhancements) and are indeed cases where you can export from a later release of Oracle and import into an earlier release.

For full secrets and tips for exporting and importing between releases, see the book Advanced Oracle Utilities: The Definitive Reference.
In some cases an older export is indeed backward compatible to a newer release:

Export/Import between different releases of Oracle

Oracle Data Pump was first released in Oracle 10g (expdp and impdp).  Priot to Data Pump, Oracle used the "exp" and "imp" utilities.
In your case, both the export (expdp) and import (impdp) are with Data Pump and you can use the version [parameter to export from a later release of Oracle an import that dump file into an earlier release of Oracle.
You can import your 11g expdp dump file into Oracle 10g if you make sure you use "VERSION=10.2" parameter during export.
Here is a working example of using the expdp version parameter to make a dump file acceptable to an earlier release of Oracle:
Export using the expdp version parameter:
C:\Users\Steve>expdp hr/hr TABLES=hr.employees2 VERSION=10.2 DIRECTORY=data_pump_dir DUMPFILE=emp2.dmp LOGFILE=emp2.log

Export: Release 11.2.0.1.0 - Production on Tue Sep 7 09:10:51 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

Starting "HR"."SYS_EXPORT_TABLE_01":  hr/******** TABLES=hr.employees2 VERSION=10.2 DIRECTORY=data_p
ump_dir DUMPFILE=emp2.dmp LOGFILE=emp2.log

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


. . exported "HR"."EMPLOYEES2"                           16.12 KB     107 rows


Master table "HR"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded

******************************************************************************

Dump file set for HR.SYS_EXPORT_TABLE_01 is:

  C:\APP\ORACLE\ADMIN\ORCL\DPDUMP\EMP2.DMP

Job "HR"."SYS_EXPORT_TABLE_01" successfully completed at 09:11:01

Import into earlier release of Oracle:

Here we copied the dmp file from the 11g directory to the 10g dump file location and execute expdp on the 10g instance:
DIRECTORY_NAME                 DIRECTORY_PATH
------------------------------ ----------------------------------------
DATA_PUMP_DIR                  C:\oraclexe\app\oracle\admin\XE\dpdump\
ORACLECLRDIR                   C:\oraclexe\app\oracle\product\10.2.0\se
                               rver\bin\clr


SQL> grant read, write on directory data_pump_dir to hr;

Grant succeeded.

SQL> exit
Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

C:\Users\Steve>impdp hr/hr TABLES=hr.employees2 DIRECTORY=data_pump_dir DUMPFILE=emp2.dmp LOGFILE=emp2_imp.log

Import: Release 10.2.0.1.0 - Production on Tuesday, 07 September, 2010 9:25:53

Copyright (c) 2003, 2005, Oracle.  All rights reserved.

Connected to: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

Master table "HR"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded

Starting "HR"."SYS_IMPORT_TABLE_01":  hr/******** TABLES=hr.employees2 DIRECTORY=data_pump_dir DUMPFILE=emp2.dmp LOGFILE=emp2_imp.log

Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

. . imported "HR"."EMPLOYEES2"                           16.12 KB     107 rows


Job "HR"."SYS_IMPORT_TABLE_01" successfully completed at 09:26:05



C:\Users\Steve>sqlplus hr/hr

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Sep 7 09:26:37 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production

SQL> select count(*) from employees2;

  COUNT(*)
----------
       107

No comments:

Post a Comment