HOW TO TAKE EXPORT BACKUP/IMPORT OF TABLES

When preparing to taking export backup of application tables from a target database(source) and importing to another database(destination),
You need to do the following:

1. You need to create directory where the dump file to be created with reside.

CREATE DIRECTORY DUMPDIR AS '<filesystem_path with enough space>';
example:
CREATE DIRECTORY DUMPDIR AS '/u01/export/dumpdir';

2. Grant required permission to the directory.

GRANT READ, WRITE ON DIRECTORY DUMPDIR TO <USERNAME>;

3. Select the properties of the objects/tables to be exported in the source database.

select owner,segment_name,segment_type,tablespace_name, sum(bytes/1024/1024) from dba_segments where segment_name IN
('table_name','object_name','table_name','table_name'...) group by owner,segment_name,segment_type,tablespace_name ;

example:
---------------------------------------------------------------------------------------------------------------------------------
OWNER                          SEGMENT_NAME                   SEGMENT_TYPE       TABLESPACE_NAME        SUM(BYTES/1024/1024)
------------------------------ ------------------------------ ------------------ ------------------------------ ------------------

4. script the parfile for the export of the tables.

example:

EXP_<TABLE_NAME>.par
-----------------------

DUMPFILE=<TABLE_NAME><DDMMMYY>_%U.dmp

DIRECTORY=DUMPDIR

TABLES=<SCHEMA>.<TABLE_NAME>

LOGFILE=<EXP_TABLE_NAME>.log

PARALLEL=4

CONTENT=DATA_ONLY
EXCLUDE=TRIGGER,CONSTRAINT,INDEX


5. Initiate the export backup while inside the dump directory path created above with below command:

expdp parfile=EXP_<TABLE_NAME>.par

Then follow step 1 through 3 to prepare for the import of the dump file to the destination database.

6. script the parfile for the import of the table.

impdp parfile=IMP_<TABLE_NAME>.par   
---------------------------------

DUMPFILE=<TABLE_NAME><DDMMMYY>_%U.dmp
DIRECTORY=DUMPDIR
LOGFILE=<IMP_TABLE_NAME>.log
PARALLEL=4
remap_schema=<source_schema>:<destination_schema>
remap_tablespace=<source_tablespace>:<destination_tablespace>
TABLE_EXISTS_ACTION=truncate
commit=n
buffer=64000


7. Initiate the import of the table with the below command:

impdp parfile=IMP_<TABLE_NAME>.par

Comments

Popular posts from this blog

How to resolve - ORA-09925: Unable to create audit trail file

How to repair a disk in a diskgroup