Quantcast
Channel: Oracle DBA - RajaBaskar Blog
Viewing all articles
Browse latest Browse all 25

Version parameter in oracle expdp and impdp

$
0
0


Data migration using expdp/impdp without any version conflict

 I am frequently getting data migration from one database to another database across all the oracle/OS platform version.

Whenever we are migrating the data using expdp/impdp or exp/imp, we should use the lower version exp binary  (Oracle Home) for expdp/exp.

My requirement:

Copy one schema from 11g database to 10g database.

Example:

we are exporting 11g database schema and import into 10g database, We should use 10g Binary for export. Every time this one is very challenging to me and anyone…

If I take export 11g data  using oracle 11g binary, while import into 10g database won’t support.  

I have 2 option:

1)     Use if any other ORACLE HOME (10g) for export is available on same server. Only 11g database is running on my database server.
2)     Install 10g oracle software on same server and start the export.
3)     Using DBLINK, we can copy the data .. L

I will plan to install 10g software on DB server , so I contact core DBA team and explained why we need 10g s/w ? . One of my friend from core team, he said “ Raja, recently I heard about version parameter.. I am not aware that much.. you can check ..”

I have checked that parameter in my test environment successfully and did in production also…always this parameter will help us to save unnecessary issue..


Test Case:

Source Database:

Oracle Version: 11.1.0.7

SQL> create user rb identified by rb;

User created.

SQL> grant connect,resource,dba to rb;

Grant succeeded.

SQL> connect rb/rb
Connected.
SQL> create table rb_objects as select * from dba_objects;

Table created.

SQL> select count(*) from rb.rb_objects;

  COUNT(*)
----------
    101933


Target Database:

Oracle Version: 10.2.0.3


SQL> show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      10.2.0.3.0


SQL> create user rb identified by rb;

User created.

SQL> grant connect,resource,dba to rb;

Grant succeeded.

SQL> create directory TEST_DIR as '/u01/backup/export/dump';

Directory created.

SQL>  grant read,write on directory TEST_DIR to rb;

Grant succeeded.


Source Database 11g schema export :

$expdp dumpfile=exp_rb_11g.dmp logfile=exp_rb_11g.log directory=TEST_DIR schemas=RB

Export: Release 11.1.0.7.0 - 64bit Production on Sunday, 22 April, 2012 1:31:06

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

Username: rb
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "RB"."SYS_EXPORT_SCHEMA_01":  rb/******** dumpfile=exp_rb_11g.dmp logfile=exp_rb_11g.log directory=TEST_DIR schemas=RB
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 12 MB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
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/COMMENT
Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMA
. . exported "RB"."RB_OBJECTS"                           9.956 MB  101933 rows
Master table "RB"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for RB.SYS_EXPORT_SCHEMA_01 is:
/u01/backup/export/dump/exp_rb_11g.dmp
Job "RB"."SYS_EXPORT_SCHEMA_01" successfully completed at 01:35:45

Import the 11g schema data in 10g database :


$ impdp dumpfile=exp_rb_11g.dmp logfile=imp_rb_11g_10g.log directory=TEST_DIR schemas=RB

Import: Release 10.2.0.4.0 - 64bit Production on Sunday, 22 April, 2012 1:37:31

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

Username: rb
Password:

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 2.1 in dump file "
/u01/backup/export/dump/exp_rb_11g.dmp"

Source Database 11g schema export with version parameter:


How version parameter provides the solution for this issue?

We should give the version parameter value as target database (Wherever we import) compatible parameter value.

$ expdp dumpfile=exp_rb_11g_with_version%U.dmp logfile=exp_rb_11g_with_version.log directory=TEST_DIR schemas=RB parallel=4 version=10.2.0.3.0

Export: Release 11.1.0.7.0 - 64bit Production on Sunday, 22 April, 2012 1:43:42

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

Username: rb
Password:

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "RB"."SYS_EXPORT_SCHEMA_01":  rb/******** dumpfile=exp_rb_11g_with_version%U.dmp logfile=exp_rb_11g_with_version.log directory=TEST_DIR schemas=RB parallel=4 version=10.2.0.3.0
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 12 MB
. . exported "RB"."RB_OBJECTS"                           9.956 MB  101933 rows
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
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/COMMENT
Master table "RB"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for RB.SYS_EXPORT_SCHEMA_01 is:
/u01/backup/export/dump/exp_rb_11g_with_version01.dmp
/u01/backup/export/dump/exp_rb_11g_with_version02.dmp
Job "RB"."SYS_EXPORT_SCHEMA_01" successfully completed at 01:46:31


While import we having issue with tablespace mapping –please ignore it..

$impdp dumpfile=exp_rb_11g_with_version%U.dmp logfile=imp_rb_11g_10g_with_version.log directory=TEST_DIR schemas=RB parallel=4 version=10.2.0.3.0

Import: Release 10.2.0.4.0 - 64bit Production on Sunday, 22 April, 2012 1:50:43

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

Username: rb
Password:

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 "RB"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "RB"."SYS_IMPORT_SCHEMA_01":  rb/******** dumpfile=exp_rb_11g_with_version%U.dmp logfile=imp_rb_11g_10g_with_version.log directory=TEST_DIR schemas=RB parallel=4 version=10.2.0.3.0
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"RB" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
ORA-39083: Object type TABLE failed to create with error:
ORA-00959: tablespace 'USERS' does not exist
Failing sql is:
CREATE TABLE "RB"."RB_OBJECTS" ("OWNER" VARCHAR2(30), "OBJECT_NAME" VARCHAR2(128), "SUBOBJECT_NAME" VARCHAR2(30), "OBJECT_ID" NUMBER, "DATA_OBJECT_ID" NUMBER, "OBJECT_TYPE" VARCHAR2(19), "CREATED" DATE, "LAST_DDL_TIME" DATE, "TIMESTAMP" VARCHAR2(19), "STATUS" VARCHAR2(7), "TEMPORARY" VARCHAR2(1), "GENERATED" VARCHAR2(1), "SECONDARY" VARCHAR2(1), "NAMESPACE" NUMBER, "EDITION_NAME" VARCHAR2
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Job "RB"."SYS_IMPORT_SCHEMA_01" completed with 2 error(s) at 01:50:57


Import the 11g schema data in 10g using version parameter,

impdp dumpfile=exp_rb_11g_with_version%U.dmp logfile=imp_rb_11g_10g_with_version.log directory=TEST_DIR schemas=RB parallel=4 version=10.2.0.3.0 remap_tablespace=USERS:AIAD1_TBL_01

Import: Release 10.2.0.4.0 - 64bit Production on Sunday, 22 April, 2012 1:54:41

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

Username: rb
Password:

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 "RB"."SYS_IMPORT_SCHEMA_01" successfully loaded/unloaded
Starting "RB"."SYS_IMPORT_SCHEMA_01":  rb/******** dumpfile=exp_rb_11g_with_version%U.dmp logfile=imp_rb_11g_10g_with_version.log directory=TEST_DIR schemas=RB parallel=4 version=10.2.0.3.0 remap_tablespace=USERS:AIAD1_TBL_01
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"RB" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "RB"."RB_OBJECTS"                           9.956 MB  101933 rows
Job "RB"."SYS_IMPORT_SCHEMA_01" completed with 1 error(s) at 01:54:57


If you have any issue/getting any error while import, just import object structure only first (CONTENT=METADATA_ONLY Parameter). Next you can import data separately (CONTENT=DATA_ONLY parameter).


I Hope this article helped you. Suggestions are welcome.

Best Regards
RajaBaskar Thangaraj
rajabaskar.t@gmail.com
 

Viewing all articles
Browse latest Browse all 25

Trending Articles