Sunday, October 13, 2013

transporatable tablespace

#We have 2 database i will show how to do a tablespace transport from one database to another

# in source database
#1.create a tablespace and a user using that tablespace and create a table in the user

SQL> create tablespace test_tbs;

SQL> create user test identified by test123 default tablespace test_tbs;

SQL> grant connect,resource to test;

SQL> create table test.test_tbl as select * from dba_tables;

# take the tablespace read only mode
#1.take a metadata export of the tablespace
#2.move the datafile to desired location
#3.make tablespace again read write

SQL> alter tablespace TEST_TBS read only;

SQL> exec dbms_file_transfer.COPY_FILE('ASM_SOURCE','test_tbs.548.828809123','ASM_DEST','test_tbs.test');

PL/SQL procedure successfully completed.

[oracle@subhen_db EXPDP]$ expdp directory=EXPDP_DIR transport_tablespaces=TEST_TBS dumpfile=TEST_TBS.dmp logfile=TEST_TBS_exp.log REUSE_DUMPFILES=Y

#in target database
#try to import the dumpfile

[oracle@subhen_db EXPDP]$ cat import.par
directory=EXPDP_DIR
dumpfile=TEST_TBS.dmp
logfile=TEST_TBS_impdp.log
transport_datafiles='+DATA/TARGET_DB/DATAFILE/test_tbs.test'

#import failed as user doesnot exist

[oracle@subhen_db EXPDP]$ impdp parfile=import.par
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
ORA-39123: Data Pump transportable tablespace job aborted
ORA-29342: user TEST does not exist in the database

#create the user in the target database

SQL> create user test identified by test123;

# IMPORT it again

[oracle@subhen_db EXPDP]$ impdp parfile=import.par

Import: Release 11.2.0.3.0 - Production on Mon Oct 14 17:00:49 2013

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

Username: / as sysdba

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
Master table "SYS"."SYS_IMPORT_TRANSPORTABLE_05" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TRANSPORTABLE_05":  /******** AS SYSDBA parfile=import.par
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYS"."SYS_IMPORT_TRANSPORTABLE_05" successfully completed at 17:01:18









1 comment:

  1. Great work sahu...

    Do check my blog also...

    http://neerajsthakur.blogspot.in/

    ReplyDelete