Sunday, June 29, 2014

Table Exports/Imports Using Oracle Data Pump

1. You need to create directory (If you already created no need to create) from sys schema.

Example :
CREATE OR REPLACE DIRECTORY
DATA_DIR AS
'D:\DUMP\';

2. You need to given read & write permeation to specific user which you want to export. 
GRANT READ, WRITE ON DIRECTORY DATA_DIR TO RND;

3. Now you can export list of tables using data pump

You need to connect specific schema which tables you want to export ..

For export

expdp rnd/rnd@orcl TABLES=EMP,DEPT DIRECTORY=DATA_DIR DUMPFILE=EXP_EMP_DEPT.DMP LOGFILE=EXP_EMP_DEPT.LOG

For import (TABLE_EXISTS_ACTION=APPEND parameter allows data to be imported into existing tables.)

impdp rnd/rnd@orcl TABLES=EMP,DEPT DIRECTORY=DATA_DIR TABLE_EXISTS_ACTION=APPEND DUMPFILE=EXP_EMP_DEPT.DMP LOGFILE=IMP_EMP_DEPT.LOG


C:\Users\rajib.pradhan>expdp rnd/rnd@orcl TABLES=EMP,DEPT DIRECTORY=DATA_DIR DUMPFILE=EXP_EMP_DEPT.DMP LOGFILE=EXP_EMP_DEPT.LOG

Export: Release 11.2.0.1.0 - Production on Sun Jun 29 16:56:41 2014

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 "RND"."SYS_EXPORT_TABLE_01":  rnd/********@orcl TABLES=EMP,DEPT DIRECTORY=DATA_DIR DUMPFILE=EXP_EMP_DEPT.DMP LOGFILE=EXP_EMP_DEPT.LOG
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 128 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "RND"."DEPT"                                7.023 KB      28 rows
. . exported "RND"."EMP"                                 16.83 KB     107 rows
Master table "RND"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for RND.SYS_EXPORT_TABLE_01 is:
  D:\DUMP\EXP_EMP_DEPT.DMP
Job "RND"."SYS_EXPORT_TABLE_01" successfully completed at 16:57:12


C:\Users\rajib.pradhan>impdp rnd/rnd@orcl TABLES=EMP,DEPT DIRECTORY=DATA_DIR TABLE_EXISTS_ACTION=APPEND DUMPFILE=EXP_EMP_DEPT.DMP LOGFILE=IMP_EMP_DEPT.LOG

Import: Release 11.2.0.1.0 - Production on Sun Jun 29 16:58:29 2014

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
Master table "RND"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "RND"."SYS_IMPORT_TABLE_01":  rnd/********@orcl TABLES=EMP,DEPT DIRECTORY=DATA_DIR TABLE_EXISTS_ACTION=APPEND DUMPFILE=EXP_EMP_DEPT.DMP LOGFILE=IMP_EMP_DEPT.LOG
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39152: Table "RND"."EMP" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
ORA-39152: Table "RND"."DEPT" exists. Data will be appended to existing table but all dependent metadata will be skipped due to table_exists_action of append
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "RND"."DEPT"                                7.023 KB      28 rows
. . imported "RND"."EMP"                                 16.83 KB     107 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "RND"."SYS_IMPORT_TABLE_01" completed with 2 error(s) at 16:58:35

No comments:

Post a Comment