HOW TO EXPORT DATA FROM REMOTE DATABASE USING DATAPUMP.
In this article, we will see how to export data from remote database and import in source database.
Source Database :
iP address : 192.168.0.51
Instance Name : primary
Remote Database :
iP address : 192.168.0.61
Instance Name : orcl
Steps to implement :
1.Networking b/w hosts (Both Source and Remote servers should ping each other)
2.Create & start listener.ora in Remote server.
3.create tnsnames.ora in Source server .
4.In source database choose one user and create database link.
5.check database link by selecting data
6.In source server perform EXPDP operation using network_link
7.Import data into source database using dumpfile
Now implement above steps :
Step 1 :
Networking b/w hosts (Both Source and Remote servers should ping each other)
Remote Server :
Step 2 :
Create & start listener.ora in Remote server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
vi listener.ora scott_list = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.61)(PORT = 1565)) ) ) ) SID_LIST_scott_list = (SID_LIST = (SID_DESC = (SID_NAME =orcl) (ORACLE_HOME = /u01/app/oracle/product/12.1.0) ) ) |
Start listener
1 |
lsnrctl start scott_list |
Source Server :
Step 3 :
create tnsnames.ora in Source server .
1 2 3 4 5 6 7 8 9 10 |
$ vi tnsnames.ora scott_list = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.0.61)(PORT = 1565)) ) (CONNECT_DATA = (SID = orcl) ) ) |
1 2 3 4 5 6 7 |
[oracle@dba1 ~]$ tnsping scott_list TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 22-MAR-2019 19:03:31 Copyright (c) 1997, 2014, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.0.61)(PORT = 1565))) (CONNECT_DATA = (SID = orcl))) OK (10 msec) |
Step 4 :
In source database choose one user and create database link.
1 2 3 4 5 6 7 8 |
[oracle@dba1 ~]$ sqlplus ajay/ajay SQL*Plus: Release 12.1.0.2.0 Production on Fri Mar 22 19:04:46 2019 Copyright (c) 1982, 2014, Oracle. All rights reserved. Last Successful login time: Fri Mar 22 2019 17:21:28 +05:30 Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options AJAY>> |
Create database link
1 |
AJAY>>create database link scott_dblink connect to scott identified by tiger using 'scott_list'; |
Step 5 :
Selecting the data using database link
1 2 3 4 5 6 7 8 9 10 |
AJAY>>select * from dept@scott_dblink; DEPTNO DNAME LOC ------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON Elapsed: 00:00:00.10 |
Yes , The data is selecting through dblink from remote database.
Step 6 :
Now perform export operation by creating PAR file.
Create PAR file
1 2 |
[oracle@dba1 ajay]$ cat expdp_scott_remote.par directory=datapump tables=scott.emp,scott.dept,scott.salgrade consistent=y network_link=scott_dblink |
Now export the data
1 |
expdp ajay/ajay dumpfile=expdp_scott_tables_`date '+%d%m%Y_%H%M%S'`.dmp logfile=expdp_scott_tables_`date '+%d%m%Y_%H%M%S'`.log parfile=/home/oracle/ajay/expdp_scott_remote.par |
Execution :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
[oracle@dba1 ajay]$ expdp ajay/ajay dumpfile=expdp_scott_tables_`date '+%d%m%Y_%H%M%S'`.dmp logfile=expdp_scott_tables_`date '+%d%m%Y_%H%M%S'`.log parfile=/home/oracle/ajay/expdp_scott_remote.par Export: Release 12.1.0.2.0 - Production on Fri Mar 22 19:23:11 2019 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options Legacy Mode Active due to the following parameters: Legacy Mode Parameter: "consistent=TRUE" Location: Parameter File, Replaced with: "flashback_time=TO_TIMESTAMP('2019-03-22 19:23:11', 'YYYY-MM-DD HH24:MI:SS')" Legacy Mode has set reuse_dumpfiles=true parameter. Starting "AJAY"."SYS_EXPORT_TABLE_01": ajay/******** dumpfile=expdp_scott_tables_22032019_192307.dmp logfile=expdp_scott_tables_22032019_192307.log parfile=/home/oracle/ajay/expdp_scott_remote.par reuse_dumpfiles=true Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 192 KB Processing object type TABLE_EXPORT/TABLE/TABLE Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER . . exported "SCOTT"."DEPT" 7.015 KB 4 rows . . exported "SCOTT"."EMP" 11.27 KB 14 rows . . exported "SCOTT"."SALGRADE" 6.921 KB 5 rows Master table "AJAY"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded ****************************************************************************** Dump file set for AJAY.SYS_EXPORT_TABLE_01 is: /u01/datapump/expdp_scott_tables_22032019_192307.dmp Job "AJAY"."SYS_EXPORT_TABLE_01" successfully completed at Fri Mar 22 19:24:05 2019 elapsed 0 00:00:51 |
Check Dumpfile and Logfiles.
1 2 3 4 5 |
[oracle@dba1 datapump]$ ls -lrt total 448 -rw-r--r--. 1 oracle dba 1901 Mar 22 17:21 Impdp_refresh_metadata_tables_sepwmsa1_22-Mar-2019.log -rw-r-----. 1 oracle dba 221184 Mar 22 19:24 expdp_scott_tables_22032019_192307.dmp -rw-r--r--. 1 oracle dba 2012 Mar 22 19:24 expdp_scott_tables_22032019_192307.log |
Step 7 :
Perform import operation to source database using dumpfile
Create Parfile
1 2 |
[oracle@dba1 ajay]$ cat import.par directory=datapump remap_schema=scott:ajay table_exists_action=truncate tables=scott.emp,scott.dept,scott.salgrade |
Perform import operation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[oracle@dba1 ajay]$ impdp dumpfile=expdp_scott_tables_22032019_192307.dmp logfile=no parfile=import.par Import: Release 12.1.0.2.0 - Production on Fri Mar 22 19:32:30 2019 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Username: ajay/ajay Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options Master table "AJAY"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded Starting "AJAY"."SYS_IMPORT_TABLE_01": ajay/******** dumpfile=expdp_scott_tables_22032019_192307.dmp logfile=no parfile=import.par Processing object type TABLE_EXPORT/TABLE/TABLE Table "AJAY"."DEPT" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "AJAY"."EMP" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "AJAY"."SALGRADE" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Processing object type TABLE_EXPORT/TABLE/TABLE_DATA . . imported "AJAY"."DEPT" 7.015 KB 4 rows . . imported "AJAY"."EMP" 11.27 KB 14 rows . . imported "AJAY"."SALGRADE" 6.921 KB 5 rows Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER Job "AJAY"."SYS_IMPORT_TABLE_01" successfully completed at Fri Mar 22 19:32:48 2019 elapsed 0 00:00:12 |
In above import operation , if tables already exists it will truncate those tables and then data will be imported.
Performing Import without dumpfile using network_link
On Source database :
Perform import operation use same parfile
1 2 |
$ cat import.par directory=datapump remap_schema=scott:ajay table_exists_action=truncate tables=scott.emp,scott.dept,scott.salgrade |
import operation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
[oracle@dba1 ajay]$ impdp logfile=no parfile=import.par network_link=scott_dblink Import: Release 12.1.0.2.0 - Production on Fri Mar 22 19:35:51 2019 Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved. Username: ajay Password: Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options Starting "AJAY"."SYS_IMPORT_TABLE_01": ajay/******** logfile=no parfile=import.par network_link=scott_dblink Estimate in progress using BLOCKS method... Processing object type TABLE_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 192 KB Processing object type TABLE_EXPORT/TABLE/TABLE Table "AJAY"."DEPT" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "AJAY"."EMP" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate Table "AJAY"."SALGRADE" exists and has been truncated. Data will be loaded but all dependent metadata will be skipped due to table_exists_action of truncate . . imported "AJAY"."DEPT" 4 rows . . imported "AJAY"."EMP" 14 rows . . imported "AJAY"."SALGRADE" 5 rows Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/CONSTRAINT Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER Job "AJAY"."SYS_IMPORT_TABLE_01" successfully completed at Fri Mar 22 19:36:07 2019 elapsed 0 00:00:10 |
In above import operation , if tables already exists it will truncate those tables and then data will be imported without generating dumpfiles and logfiles
Thank you……