ORACLE-BASE - Oracle Data Pump (Expdp and Impdp) in Oracle Database 10g
ORACLE-BASE - Oracle Data Pump (Expdp and Impdp) in Oracle Database 10g
Home Articles Scripts Forums Blog Certification Misc About Printer Friendly
Oracle 8i | Oracle 9i | Oracle 10g | Oracle 11g | Oracle 12c | Miscellaneous | PL/SQL | SQL | Oracle RAC | Oracle Apps | Linux
Getting Started
Table Exports/Imports
Schema Exports/Imports
Database Exports/Imports
INCLUDE and EXCLUDE
Network Exports/Imports (NETWORK_LINK)
Flashback Exports
Miscellaneous Information
Data Pump API
External Tables
Help
expdp
impdp
Related articles.
Data Pump Enhancements in Oracle Database 11g Release 1 (expdp and impdp)
Data Pump Enhancements in Oracle Database 12c Release 1 (expdp and impdp)
SQL Developer 3.1 Data Pump Wizards (expdp, impdp)
Transportable Tablespaces
Getting Started
For the examples to work we must first unlock the SCOTT account and create a directory object it can access. The directory object is only a pointer to a physical directory, creating it does
not actually create the physical directory on the file system of the database server.
CONN / AS SYSDBA
ALTER USER scott IDENTIFIED BY tiger ACCOUNT UNLOCK;
Note. Data Pump is a server-based technology, so it typically deals with directory objects pointing to physical directories on the database server. It does not write to the local file system on
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 1/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
your client PC.
Table Exports/Imports
The TABLESparameter is used to specify the tables that are to be exported. The following is an example of the table export and import syntax.
Dịch
expdp scott/tiger@db10g tables=EMP,DEPT directory=TEST_DIR dumpfile=EMP_DEPT.dmp logfile=expdpEMP_DEPT.log
Schema Exports/Imports
The OWNERparameter of exp has been replaced by the SCHEMASparameter which is used to specify the schemas to be exported. The following is an example of the schema export and
import syntax.
Database Exports/Imports
The FULLparameter indicates that a complete database export is required. The following is an example of the full database export and import syntax.
INCLUDE=object_type[:name_clause] [, ...]
EXCLUDE=object_type[:name_clause] [, ...]
The following code shows how they can be used as command line parameters.
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 2/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
If the parameter is used from the command line, depending on your OS, the special characters in the clause may need to be escaped, as follows. Because of this, it is easier to use a
parameter file.
A single import/export can include multiple references to the parameters, so to export tables, views and some packages we could use either of the following approaches.
INCLUDE=TABLE,VIEW,PACKAGE:"LIKE '%API'"
or
INCLUDE=TABLE
INCLUDE=VIEW
INCLUDE=PACKAGE:"LIKE '%API'"
Multiple objects can be targeted in once statement using the LIKEand INoperators.
EXCLUDE=SCHEMA:"LIKE 'SYS%'"
EXCLUDE=SCHEMA:"IN ('OUTLN','SYSTEM','SYSMAN','FLOWS_FILES','APEX_030200','APEX_PUBLIC_USER','ANONYMOUS')"
The valid object type paths that can be included or excluded can be displayed using the DATABASE_EXPORT_OBJECTS, SCHEMA_EXPORT_OBJECTS, and TABLE_EXPORT_OBJECTS
views.
CONN / AS SYSDBA
GRANT CREATE DATABASE LINK TO test;
CONN test/test
CREATE DATABASE LINK remote_scott CONNECT TO scott IDENTIFIED BY tiger USING 'DEV';
In the case of exports, the NETWORK_LINKparameter identifies the database link pointing to the source server. The objects are exported from the source server in the normal manner, but
written to a directory object on the local server, rather than one on the source server. Both the local and remote users require the EXP_FULL_DATABASErole granted to them.
For imports, the NETWORK_LINKparameter also identifies the database link pointing to the source server. The difference here is the objects are imported directly from the source into the
local server without being written to a dump file. Although there is no need for a DUMPFILEparameter, a directory object is still required for the logs associated with the operation. Both the
local and remote users require the IMP_FULL_DATABASErole granted to them.
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 3/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
Flashback Exports
The exputility used the CONSISTENT=Yparameter to indicate the export should be consistent to a point in time. By default the expdputility exports are only consistent on a per table
basis. If you want all tables in the export to be consistent to the same point in time, you need to use the FLASHBACK_SCNor FLASHBACK_TIMEparameter.
The FLASHBACK_TIMEparameter value is converted to the approximate SCN for the specified time.
# In parameter file.
flashback_time="to_timestamp('09-05-2011 09:00:00', 'DD-MM-YYYY HH24:MI:SS')"
Not surprisingly, you can make exports consistent to an earlier point in time by specifying an earlier time or SCN, provided you have enough UNDO space to keep a read consistent view of
the data during the export operation.
If you prefer to use the SCN, you can retrieve the current SCN using one of the following queries.
The following queries may prove useful for converting between timestamps and SCNs.
In 11.2, the introduction of legacy mode means that you can use the CONSISTENT=Yparameter with the expdputility if you wish.
Miscellaneous Information
Unlike the original exp and imp utilities all data pump ".dmp" and ".log" files are created on the Oracle server, not the client machine.
All data pump actions are performed by multiple jobs (server processes not DBMS_JOB jobs). These jobs are controlled by a master control process which uses Advanced Queuing. At
runtime an advanced queue table, named after the job name, is created and used by the master control process. The table is dropped on completion of the data pump job. The job and the
advanced queue can be named using the JOB_NAMEparameter. Cancelling the client process does not stop the associated data pump job. Issuing "ctrl+c" on the client during a job stops
the client output and presents a command prompt. Typing "status" at this prompt allows you to monitor the current job.
Export> status
Job: SYS_EXPORT_FULL_01
Operation: EXPORT
Mode: FULL
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 4/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
State: EXECUTING
Bytes Processed: 0
Current Parallelism: 1
Job Error Count: 0
Dump File: D:\TEMP\DB10G.DMP
bytes written: 4,096
Worker 1 Status:
State: EXECUTING
Object Schema: SYSMAN
Object Name: MGMT_CONTAINER_CRED_ARRAY
Object Type: DATABASE_EXPORT/SCHEMA/TYPE/TYPE_SPEC
Completed Objects: 261
Total Objects: 261
Data pump performance can be improved by using the PARALLELparameter. This should be used in conjunction with the "%U" wildcard in the DUMPFILEparameter to allow multiple
dumpfiles to be created or read. The same wildcard can be used during the import to allow you to reference multiple files.
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 5/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
DBMS_DATAPUMP.add_file(
handle => l_dp_handle,
filename => 'SCOTT.dmp',
directory => 'TEST_DIR');
DBMS_DATAPUMP.add_file(
handle => l_dp_handle,
filename => 'SCOTT.log',
directory => 'TEST_DIR',
filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
DBMS_DATAPUMP.metadata_filter(
handle => l_dp_handle,
name => 'SCHEMA_EXPR',
value => '= ''SCOTT''');
DBMS_DATAPUMP.start_job(l_dp_handle);
DBMS_DATAPUMP.detach(l_dp_handle);
END;
/
Once the job has started the status can be checked using.
External Tables
Oracle have incorporated support for data pump technology into external tables. The ORACLE_DATAPUMP access driver can be used to unload data to data pump export files and
subsequently reload it. The unload of data occurs when the external table is created using the "AS" clause.
The syntax to create the external table pointing to an existing file is similar, but without the "AS" clause.
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 6/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
CREATE TABLE emp_xt (
EMPNO NUMBER(4),
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2))
ORGANIZATION EXTERNAL (
TYPE ORACLE_DATAPUMP
DEFAULT DIRECTORY test_dir
LOCATION ('emp_xt.dmp')
);
Help
The HELP=Yoption displays the available parameters.
expdp
expdp help=y
The Data Pump export utility provides a mechanism for transferring data objects
between Oracle databases. The utility is invoked with the following command:
You can control how Export runs by entering the 'expdp' command followed
by various parameters. To specify parameters, you use keywords:
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 7/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
ESTIMATE Calculate job estimates where the valid keywords are:
(BLOCKS) and STATISTICS.
ESTIMATE_ONLY Calculate job estimates without performing the export.
EXCLUDE Exclude specific object types, e.g. EXCLUDE=TABLE:EMP.
FILESIZE Specify the size of each dumpfile in units of bytes.
FLASHBACK_SCN SCN used to set session snapshot back to.
FLASHBACK_TIME Time used to get the SCN closest to the specified time.
FULL Export entire database (N).
HELP Display Help messages (N).
INCLUDE Include specific object types, e.g. INCLUDE=TABLE_DATA.
JOB_NAME Name of export job to create.
LOGFILE Log file name (export.log).
NETWORK_LINK Name of remote database link to the source system.
NOLOGFILE Do not write logfile (N).
PARALLEL Change the number of active workers for current job.
PARFILE Specify parameter file.
QUERY Predicate clause used to export a subset of a table.
SCHEMAS List of schemas to export (login schema).
STATUS Frequency (secs) job status is to be monitored where
the default (0) will show new status when available.
TABLES Identifies a list of tables to export - one schema only.
TABLESPACES Identifies a list of tablespaces to export.
TRANSPORT_FULL_CHECK Verify storage segments of all tables (N).
TRANSPORT_TABLESPACES List of tablespaces from which metadata will be unloaded.
VERSION Version of objects to export where valid keywords are:
(COMPATIBLE), LATEST, or any valid database version.
Command Description
------------------------------------------------------------------------------
ADD_FILE Add dumpfile to dumpfile set.
ADD_FILE=dumpfile-name
CONTINUE_CLIENT Return to logging mode. Job will be re-started if idle.
EXIT_CLIENT Quit client session and leave job running.
HELP Summarize interactive commands.
KILL_JOB Detach and delete job.
PARALLEL Change the number of active workers for current job.
PARALLEL=.
START_JOB Start/resume current job.
STATUS Frequency (secs) job status is to be monitored where
the default (0) will show new status when available.
STATUS=[interval]
STOP_JOB Orderly shutdown of job execution and exits the client.
STOP_JOB=IMMEDIATE performs an immediate shutdown of the
Data Pump job.
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 8/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
COMPRESSION Reduce size of dumpfile contents where valid
keyword values are: (METADATA_ONLY) and NONE.
ENCRYPTION_PASSWORD Password key for creating encrypted column data.
SAMPLE Percentage of data to be exported;
Command Description
------------------------------------------------------------------------------
FILESIZE Default filesize (bytes) for subsequent ADD_FILE commands.
Command Description
------------------------------------------------------------------------------
REUSE_DUMPFILES Overwrite destination dump file if it exists (N).
Oracle 11g Release 2 (11.2) altered the format of the help output as well as adding the following parameters.
CLUSTER
Utilize cluster resources and distribute workers across the Oracle RAC.
Valid keyword values are: [Y] and N.
SERVICE_NAME
Name of an active Service and associated resource group to constrain Oracle RAC resources.
SOURCE_EDITION
Edition to be used for extracting metadata.
COMPRESSION_ALGORITHM
Specify the compression algorithm that should be used.
Valid keyword values are: [BASIC], LOW, MEDIUM and HIGH.
ENCRYPTION_PWD_PROMPT
Specifies whether to prompt for the encryption password.
Terminal echo will be suppressed while standard input is read.
VIEWS_AS_TABLES
Identifies one or more views to be exported as tables.
For example, VIEWS_AS_TABLES=HR.EMP_DETAILS_VIEW.
impdp
impdp help=y
The Data Pump Import utility provides a mechanism for transferring data objects
between Oracle databases. The utility is invoked with the following command:
You can control how Import runs by entering the 'impdp' command followed
by various parameters. To specify parameters, you use keywords:
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 11/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
Keyword Description (Default)
------------------------------------------------------------------------------
ENCRYPTION_PASSWORD Password key for accessing encrypted column data.
This parameter is not valid for network import jobs.
Oracle 11g Release 2 (11.2) altered the format of the help output as well as adding the following parameters.
CLUSTER
Utilize cluster resources and distribute workers across the Oracle RAC.
Valid keyword values are: [Y] and N.
SERVICE_NAME
Name of an active Service and associated resource group to constrain Oracle RAC resources.
SOURCE_EDITION
Edition to be used for extracting metadata.
TARGET_EDITION
Edition to be used for loading metadata.
ENCRYPTION_PWD_PROMPT
Specifies whether to prompt for the encryption password.
Terminal echo will be suppressed while standard input is read.
TRANSPORTABLE
Options for choosing transportable data movement.
Valid keywords are: ALWAYS and [NEVER].
Only valid in NETWORK_LINK mode import operations.
VIEWS_AS_TABLES
Identifies one or more views to be imported as tables.
For example, VIEWS_AS_TABLES=HR.EMP_DETAILS_VIEW.
Note that in network import mode, a table name may be appended
to the view name.
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 12/13
Ngày 4 tháng 9 năm 2014 ORACLE-BASE - Oracle Data Pump (expdp and impdp) in Oracle Database 10g
Oracle Database Utilities 10g Release 1 (10.1)
Oracle Database Utilities 10g Release 2 (10.2)
Oracle Database Utilities 11g Release 1 (11.1)
Oracle Database Utilities 11g Release 2 (11.2)
Data Pump Enhancements in Oracle Database 11g Release 1
Data Pump Enhancements in Oracle Database 12c Release 1 (expdp and impdp)
SQL Developer 3.1 Data Pump Wizards (expdp, impdp)
Transportable Tablespaces
http://www.oracle-base.com/articles/10g/oracle-data-pump-10g.php 13/13