Oracle EXPDP和IMPDP指令详解

概要

Oracle 11g及以上版本提供了数据泵技术,可以用来进行数据库的逻辑备份和恢复,Oracle建议使用数据泵来代替EXP和IMP技术。数据泵技术基于Oracle数据库服务器,导入导出的数据文件也保存在数据库服务器端,而EXP/IMP基于客户机运行。利用数据泵技术,Oracle要求必须使用目录对象,以防止用户误操作服务器上特定目录下的操作系统文件。

EXPDP数据访问方法
外部表:从操作系统文件中读取数据;
直接路径:使用直接路径API,很好改善了导入导出性能,因为内部流的数据格式和存储在备份文件中的数据格式相同,减少了数据转换的时间。

查询默认的目录对象
SQL> set linesize 200
SQL> SELECT * FROM dba_directories t
  2  WHERE t.directory_name = 'DATA_PUMP_DIR';

OWNER                          DIRECTORY_NAME                 DIRECTORY_PATH
------------------------------ ------------------------------ -----------------------------------
SYS                            DATA_PUMP_DIR                  E:appalen.liuadminorcldpdump
创建恢复目录需要CREATE ANY DIRECTORY权限;
SQL> grant create any directory to scott;

Grant succeeded.

SQL> alter session set current_schema=scott;

Session altered.

SQL> create directory scott_pump as 'd:pump';

Directory created.

SQL>
EXPDP导出技术演示

EXPDP参数
D:ackup>expdp help=y

Export: Release 11.2.0.1.0 - Production on Tue Jun 27 17:13:24 2017

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


The Data Pump export utility provides a mechanism for transferring data objects
between Oracle databases. The utility is invoked with the following command:

   Example: expdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp

You can control how Export runs by entering the 'expdp' command followed
by various parameters. To specify parameters, you use keywords:

   Format:  expdp KEYWORD=value or KEYWORD=(value1,value2,...,valueN)
   Example: expdp scott/tiger DUMPFILE=scott.dmp DIRECTORY=dmpdir SCHEMAS=scott
               or TABLES=(T1:P1,T1:P2), if T1 is partitioned table

USERID must be the first parameter on the command line.

------------------------------------------------------------------------------

The available keywords and their descriptions follow. Default values are listed within square brackets.

ATTACH
Attach to an existing job.
For example, ATTACH=job_name.

COMPRESSION
Reduce the size of a dump file.
Valid keyword values are: ALL, DATA_ONLY, [METADATA_ONLY] and NONE.

CONTENT
Specifies data to unload.
Valid keyword values are: [ALL], DATA_ONLY and METADATA_ONLY.

DATA_OPTIONS
Data layer option flags.
Valid keyword values are: XML_CLOBS.

DIRECTORY
Directory object to be used for dump and log files.

DUMPFILE
Specify list of destination dump file names [expdat.dmp].
For example, DUMPFILE=scott1.dmp, scott2.dmp, dmpdir:scott3.dmp.

ENCRYPTION
Encrypt part or all of a dump file.
Valid keyword values are: ALL, DATA_ONLY, ENCRYPTED_COLUMNS_ONLY, METADATA_ONLY and NONE.

ENCRYPTION_ALGORITHM
Specify how encryption should be done.
Valid keyword values are: [AES128], AES192 and AES256.

ENCRYPTION_MODE
Method of generating encryption key.
Valid keyword values are: DUAL, PASSWORD and [TRANSPARENT].

ENCRYPTION_PASSWORD
Password key for creating encrypted data within a dump file.

ESTIMATE
Calculate job estimates.
Valid keyword values are: [BLOCKS] and STATISTICS.

ESTIMATE_ONLY
Calculate job estimates without performing the export.

EXCLUDE
Exclude specific object types.
For example, EXCLUDE=SCHEMA:"='HR'".

FILESIZE
Specify the size of each dump file in units of bytes.

FLASHBACK_SCN
SCN used to reset session snapshot.

FLASHBACK_TIME
Time used to find the closest corresponding SCN value.

FULL
Export entire database [N].

HELP
Display Help messages [N].

INCLUDE
Include specific object types.
For example, INCLUDE=TABLE_DATA.

JOB_NAME
Name of export job to create.

LOGFILE
Specify log file name [export.log].

NETWORK_LINK
Name of remote database link to the source system.

NOLOGFILE
Do not write log file [N].

PARALLEL
Change the number of active workers for current job.

PARFILE
Specify parameter file name.

QUERY
Predicate clause used to export a subset of a table.
For example, QUERY=employees:"WHERE department_id > 10".

REMAP_DATA
Specify a data conversion function.
For example, REMAP_DATA=EMP.EMPNO:REMAPPKG.EMPNO.

REUSE_DUMPFILES
Overwrite destination dump file if it exists [N].

SAMPLE
Percentage of data to be exported.

SCHEMAS
List of schemas to export [login schema].

SOURCE_EDITION
Edition to be used for extracting metadata.

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.
For example, TABLES=HR.EMPLOYEES,SH.SALES:SALES_1995.

TABLESPACES
Identifies a list of tablespaces to export.

TRANSPORTABLE
Specify whether transportable method can be used.
Valid keyword values are: ALWAYS and [NEVER].

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.
Valid keyword values are: [COMPATIBLE], LATEST or any valid database version.

------------------------------------------------------------------------------

The following commands are valid while in interactive mode.
Note: abbreviations are allowed.

ADD_FILE
Add dumpfile to dumpfile set.

CONTINUE_CLIENT
Return to logging mode. Job will be restarted if idle.

EXIT_CLIENT
Quit client session and leave job running.

FILESIZE
Default filesize (bytes) for subsequent ADD_FILE commands.

HELP
Summarize interactive commands.

KILL_JOB
Detach and delete job.

PARALLEL
Change the number of active workers for current job.

REUSE_DUMPFILES
Overwrite destination dump file if it exists [N].

START_JOB
Start or resume current job.
Valid keyword values are: SKIP_CURRENT.

STATUS
Frequency (secs) job status is to be monitored where
the default [0] will show new status when available.

STOP_JOB
Orderly shutdown of job execution and exits the client.
Valid keyword values are: IMMEDIATE.
演示:
1)导出整个数据库
D:>expdp sys directory=sys_pump dumpfile=wholedb_%u.dat filesize=100m job_name=alen full=y

Export: Release 11.2.0.1.0 - Production on Wed Jun 28 09:06:24 2017

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

UDE-01017: operation generated ORACLE error 1017
ORA-01017: invalid username/password; logon denied

Username: sys as sysdba
Password:

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 "SYS"."ALEN":  sys/******** AS SYSDBA directory=sys_pump dumpfile=wholedb_%u.dat filesize=100m job_name=alen full=y
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 153.0 MB
Processing object type DATABASE_EXPORT/TABLESPACE
Processing object type DATABASE_EXPORT/PROFILE
Processing object type DATABASE_EXPORT/SYS_USER/USER
Processing object type DATABASE_EXPORT/SCHEMA/USER
Processing object type DATABASE_EXPORT/ROLE
Processing object type DATABASE_EXPORT/GRANT/SYSTEM_GRANT/PROC_SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/GRANT/SYSTEM_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/ROLE_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/DEFAULT_ROLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLESPACE_QUOTA
Processing object type DATABASE_EXPORT/RESOURCE_COST
Processing object type DATABASE_EXPORT/TRUSTED_DB_LINK
Processing object type DATABASE_EXPORT/SCHEMA/SEQUENCE/SEQUENCE
Processing object type DATABASE_EXPORT/SCHEMA/SEQUENCE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/DIRECTORY/DIRECTORY
Processing object type DATABASE_EXPORT/DIRECTORY/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/CONTEXT
Processing object type DATABASE_EXPORT/SCHEMA/PUBLIC_SYNONYM/SYNONYM
Processing object type DATABASE_EXPORT/SCHEMA/SYNONYM
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/INC_TYPE
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/TYPE_SPEC
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/GRANT/OWNER_GRANT/OBJECT_GRANT
---------------------省略中间部分--------------------------------
. . exported "SYSTEM"."REPCAT$_USER_PARM_VALUES"             0 KB       0 rows
. . exported "SYSTEM"."SQLPLUS_PRODUCT_PROFILE"              0 KB       0 rows
Master table "SYS"."ALEN" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.ALEN is:
  D:BACKUPWHOLE_01.DAT
  D:BACKUPWHOLE_02.DAT
Job "SYS"."ALEN" successfully completed at 10:25:24
2)导出某个用户
D:>expdp scott/scott@orcl directory=scott_pump dumpfile=scott.dat

Export: Release 11.2.0.1.0 - Production on Wed Jun 28 09:01:42 2017

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 "SCOTT"."SYS_EXPORT_SCHEMA_01":  scott/********@orcl directory=scott_pump dumpfile=scott.dat
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 4.187 MB
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/COMMENT
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."T_COMMISSION_BALANCE"              2.212 MB   25298 rows
. . exported "SCOTT"."DEPT"                              5.953 KB       5 rows
. . exported "SCOTT"."EMP"                               8.578 KB      14 rows
. . exported "SCOTT"."SALGRADE"                          5.937 KB      10 rows
. . exported "SCOTT"."BONUS"                                 0 KB       0 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
  D:SCOTT_PUMPSCOTT.DAT
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 09:02:12
3)导出特定的表
D:>expdp directory=sys_pump dumpfile=scott.dat tables=scott.emp,scott.dept job_name=scott;

Export: Release 11.2.0.1.0 - Production on Wed Jun 28 10:29:36 2017

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

Username: sys as sysdba
Password:

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 "SYS"."scott;":  sys/******** AS SYSDBA directory=sys_pump dumpfile=scott.dat tables=scott.emp,scott.dept job_name=scott;
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/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
. . exported "SCOTT"."DEPT"                              5.953 KB       5 rows
. . exported "SCOTT"."EMP"                               8.578 KB      14 rows
Master table "SYS"."scott;" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.scott; is:
  D:BACKUPSCOTT.DAT
Job "SYS"."scott;" successfully completed at 10:29:51
4)导出指定的表空间
D:scott_pump>expdp directory=sys_pump dumpfile=users.dat tablespaces=users

Export: Release 11.2.0.1.0 - Production on Wed Jun 28 12:30:11 2017

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

Username: sys as sysdba
Password:

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 "SYS"."SYS_EXPORT_TABLESPACE_01":  sys/******** AS SYSDBA directory=sys_pump dumpfile=users.dat tablespaces=use
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 9.312 MB
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/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "ALEN"."T_COMMISSION_BALANCE"               2.212 MB   25298 rows
. . exported "SCOTT"."T_COMMISSION_BALANCE"              2.212 MB   25298 rows
. . exported "OE"."PURCHASEORDER"                        243.9 KB     132 rows
. . exported "ALEN"."DEPT"                               5.953 KB       5 rows
. . exported "ALEN"."EMP"                                8.570 KB      14 rows
. . exported "ALEN"."SALGRADE"                           5.929 KB      10 rows
. . exported "ALEN"."T1"                                  6.75 KB     100 rows
. . exported "ALEN"."TEST"                               5.421 KB       2 rows
. . exported "ALEN"."T_FLASH"                            6.757 KB     100 rows
. . exported "OE"."PRODUCT_REF_LIST_NESTEDTAB"           12.50 KB     288 rows
. . exported "OE"."CATEGORIES_TAB"                       14.15 KB      22 rows
. . exported "OE"."SUBCATEGORY_REF_LIST_NESTEDTAB"       6.585 KB      21 rows
. . exported "SCOTT"."DEPT"                              5.953 KB       5 rows
. . exported "SCOTT"."EMP"                               8.578 KB      14 rows
. . exported "SCOTT"."SALGRADE"                          5.937 KB      10 rows
. . exported "ALEN"."BONUS"                                  0 KB       0 rows
. . exported "SCOTT"."BONUS"                                 0 KB       0 rows
. . exported "SH"."DIMENSION_EXCEPTIONS"                     0 KB       0 rows
Master table "SYS"."SYS_EXPORT_TABLESPACE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLESPACE_01 is:
  D:BACKUPUSERS.DAT
Job "SYS"."SYS_EXPORT_TABLESPACE_01" successfully completed at 12:30:32
5)导出数据以及表定义,用content参数指定,用ALL来指定导出表数据和表定义,用DATA_ONLY来指定只导出数据行,用METADATA_ONLY指定导出数据表定义;
D:>expdp scott/scott directory=scott_pump dumpfile=scott_data_only content=data_only job_name=data_only

Export: Release 11.2.0.1.0 - Production on Wed Jun 28 10:46:04 2017

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 "SCOTT"."DATA_ONLY":  scott/******** directory=scott_pump dumpfile=scott_data_only content=data_only job_name=data_only
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 4.187 MB
. . exported "SCOTT"."T_COMMISSION_BALANCE"              2.212 MB   25298 rows
. . exported "SCOTT"."DEPT"                              5.953 KB       5 rows
. . exported "SCOTT"."EMP"                               8.578 KB      14 rows
. . exported "SCOTT"."SALGRADE"                          5.937 KB      10 rows
. . exported "SCOTT"."BONUS"                                 0 KB       0 rows
Master table "SCOTT"."DATA_ONLY" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.DATA_ONLY is:
  D:SCOTT_PUMPSCOTT_DATA_ONLY.DMP
Job "SCOTT"."DATA_ONLY" successfully completed at 10:46:08
6)预估导出数据文件的大小,使用参数estimate_only来指定;
D:>expdp scott/scott directory=scott_pump estimate_only=y estimate=statistics

Export: Release 11.2.0.1.0 - Production on Wed Jun 28 10:55:18 2017

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 "SCOTT"."SYS_EXPORT_SCHEMA_01":  scott/******** directory=scott_pump estimate_only=y estimate=statistics
Estimate in progress using STATISTICS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
.  estimated "SCOTT"."T_COMMISSION_BALANCE"              2.130 MB
.  estimated "SCOTT"."EMP"                               8.203 KB
.  estimated "SCOTT"."SALGRADE"                          5.906 KB
.  estimated "SCOTT"."DEPT"                              5.896 KB
.  estimated "SCOTT"."BONUS"                                 0 KB
Total estimation using STATISTICS method: 2.150 MB
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 10:55:21

IMPDP导入技术演示

IMPDP参数
D:>impdp help=y

Import: Release 11.2.0.1.0 - Production on Wed Jun 28 10:57:43 2017

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


The Data Pump Import utility provides a mechanism for transferring data objects
between Oracle databases. The utility is invoked with the following command:

     Example: impdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp

You can control how Import runs by entering the 'impdp' command followed
by various parameters. To specify parameters, you use keywords:

     Format:  impdp KEYWORD=value or KEYWORD=(value1,value2,...,valueN)
     Example: impdp scott/tiger DIRECTORY=dmpdir DUMPFILE=scott.dmp

USERID must be the first parameter on the command line.

------------------------------------------------------------------------------

The available keywords and their descriptions follow. Default values are listed within square brackets.

ATTACH
Attach to an existing job.
For example, ATTACH=job_name.

CONTENT
Specifies data to load.
Valid keywords are: [ALL], DATA_ONLY and METADATA_ONLY.

DATA_OPTIONS
Data layer option flags.
Valid keywords are: SKIP_CONSTRAINT_ERRORS.

DIRECTORY
Directory object to be used for dump, log and sql files.

DUMPFILE
List of dumpfiles to import from [expdat.dmp].
For example, DUMPFILE=scott1.dmp, scott2.dmp, dmpdir:scott3.dmp.

ENCRYPTION_PASSWORD
Password key for accessing encrypted data within a dump file.
Not valid for network import jobs.

ESTIMATE
Calculate job estimates.
Valid keywords are: [BLOCKS] and STATISTICS.

EXCLUDE
Exclude specific object types.
For example, EXCLUDE=SCHEMA:"='HR'".

FLASHBACK_SCN
SCN used to reset session snapshot.

FLASHBACK_TIME
Time used to find the closest corresponding SCN value.

FULL
Import everything from source [Y].

HELP
Display help messages [N].

INCLUDE
Include specific object types.
For example, INCLUDE=TABLE_DATA.

JOB_NAME
Name of import job to create.

LOGFILE
Log file name [import.log].

NETWORK_LINK
Name of remote database link to the source system.

NOLOGFILE
Do not write log file [N].

PARALLEL
Change the number of active workers for current job.

PARFILE
Specify parameter file.

PARTITION_OPTIONS
Specify how partitions should be transformed.
Valid keywords are: DEPARTITION, MERGE and [NONE].

QUERY
Predicate clause used to import a subset of a table.
For example, QUERY=employees:"WHERE department_id > 10".

REMAP_DATA
Specify a data conversion function.
For example, REMAP_DATA=EMP.EMPNO:REMAPPKG.EMPNO.

REMAP_DATAFILE
Redefine datafile references in all DDL statements.

REMAP_SCHEMA
Objects from one schema are loaded into another schema.

REMAP_TABLE
Table names are remapped to another table.
For example, REMAP_TABLE=EMP.EMPNO:REMAPPKG.EMPNO.

REMAP_TABLESPACE
Tablespace object are remapped to another tablespace.

REUSE_DATAFILES
Tablespace will be initialized if it already exists [N].

SCHEMAS
List of schemas to import.

SKIP_UNUSABLE_INDEXES
Skip indexes that were set to the Index Unusable state.

SOURCE_EDITION
Edition to be used for extracting metadata.

SQLFILE
Write all the SQL DDL to a specified file.

STATUS
Frequency (secs) job status is to be monitored where
the default [0] will show new status when available.

STREAMS_CONFIGURATION
Enable the loading of Streams metadata

TABLE_EXISTS_ACTION
Action to take if imported object already exists.
Valid keywords are: APPEND, REPLACE, [SKIP] and TRUNCATE.

TABLES
Identifies a list of tables to import.
For example, TABLES=HR.EMPLOYEES,SH.SALES:SALES_1995.

TABLESPACES
Identifies a list of tablespaces to import.

TARGET_EDITION
Edition to be used for loading metadata.

TRANSFORM
Metadata transform to apply to applicable objects.
Valid keywords are: OID, PCTSPACE, SEGMENT_ATTRIBUTES and STORAGE.

TRANSPORTABLE
Options for choosing transportable data movement.
Valid keywords are: ALWAYS and [NEVER].
Only valid in NETWORK_LINK mode import operations.

TRANSPORT_DATAFILES
List of datafiles to be imported by transportable mode.

TRANSPORT_FULL_CHECK
Verify storage segments of all tables [N].

TRANSPORT_TABLESPACES
List of tablespaces from which metadata will be loaded.
Only valid in NETWORK_LINK mode import operations.

VERSION
Version of objects to import.
Valid keywords are: [COMPATIBLE], LATEST or any valid database version.
Only valid for NETWORK_LINK and SQLFILE.

------------------------------------------------------------------------------

The following commands are valid while in interactive mode.
Note: abbreviations are allowed.

CONTINUE_CLIENT
Return to logging mode. Job will be restarted 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.

START_JOB
Start or resume current job.
Valid keywords are: SKIP_CURRENT.

STATUS
Frequency (secs) job status is to be monitored where
the default [0] will show new status when available.

STOP_JOB
Orderly shutdown of job execution and exits the client.
Valid keywords are: IMMEDIATE.

1)导入指定的表空间
D:scott_pump>impdp directory=sys_pump dumpfile=users.dat tablespaces=users table_exists_action=replace

Import: Release 11.2.0.1.0 - Production on Wed Jun 28 12:32:38 2017

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

Username: sys as sysdba
Password:

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 "SYS"."SYS_IMPORT_TABLESPACE_01" successfully loaded/unloaded
Starting "SYS"."SYS_IMPORT_TABLESPACE_01":  sys/******** AS SYSDBA directory=sys_pump dumpfile=users.dat tablespaces=users table_exists_action=replac
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "ALEN"."T_COMMISSION_BALANCE"               2.212 MB   25298 rows
. . imported "SCOTT"."T_COMMISSION_BALANCE"              2.212 MB   25298 rows
. . imported "OE"."PURCHASEORDER"                        243.9 KB     132 rows
. . imported "ALEN"."DEPT"                               5.953 KB       5 rows
. . imported "ALEN"."EMP"                                8.570 KB      14 rows
. . imported "ALEN"."SALGRADE"                           5.929 KB      10 rows
. . imported "ALEN"."T1"                                  6.75 KB     100 rows
. . imported "ALEN"."TEST"                               5.421 KB       2 rows
. . imported "ALEN"."T_FLASH"                            6.757 KB     100 rows
. . imported "OE"."PRODUCT_REF_LIST_NESTEDTAB"           12.50 KB     288 rows
. . imported "OE"."CATEGORIES_TAB"                       14.15 KB      22 rows
. . imported "OE"."SUBCATEGORY_REF_LIST_NESTEDTAB"       6.585 KB      21 rows
. . imported "SCOTT"."DEPT"                              5.953 KB       5 rows
. . imported "SCOTT"."EMP"                               8.578 KB      14 rows
. . imported "SCOTT"."SALGRADE"                          5.937 KB      10 rows
. . imported "ALEN"."BONUS"                                  0 KB       0 rows
. . imported "SCOTT"."BONUS"                                 0 KB       0 rows
. . imported "SH"."DIMENSION_EXCEPTIONS"                     0 KB       0 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/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYS"."SYS_IMPORT_TABLESPACE_01" successfully completed at 12:33:06
2)导入某个特定的表
D:>impdp scott/scott directory=scott_pump tables=scott.emp,scott.dept dumpfile=scott.dat

Import: Release 11.2.0.1.0 - Production on Wed Jun 28 11:04:04 2017

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 "SCOTT"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_TABLE_01":  scott/******** directory=scott_pump tables=scott.emp,scott.dept dumpfile=scott.dat
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."DEPT"                              5.953 KB       5 rows
. . imported "SCOTT"."EMP"                               8.578 KB      14 rows
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SCOTT"."SYS_IMPORT_TABLE_01" successfully completed at 11:04:08
3)利用SQLFILE参数提取DDL语句
D:>impdp scott/scott directory=scott_pump tables=emp,dept dumpfile=scott.dat sqlfile=scott.sql

Import: Release 11.2.0.1.0 - Production on Wed Jun 28 11:21:28 2017

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 "SCOTT"."SYS_SQL_FILE_TABLE_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_SQL_FILE_TABLE_01":  scott/******** directory=scott_pump tables=emp,dept dumpfile=scott.dat sqlfile=scott.sql
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/INDEX/INDEX
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SCOTT"."SYS_SQL_FILE_TABLE_01" successfully completed at 11:21:30
4)导入指定的数据库对象
D:scott_pump>impdp scott/scott dumpfile=users.dat directory=sys_pump include=table table_exists_action=replace

Import: Release 11.2.0.1.0 - Production on Wed Jun 28 12:50:16 2017

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
ORA-39154: Objects from foreign schemas have been removed from import
Master table "SCOTT"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "SCOTT"."SYS_IMPORT_FULL_01":  scott/******** dumpfile=users.dat directory=sys_pump include=table table_exists_action=replace
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."T_COMMISSION_BALANCE"              2.212 MB   25298 rows
. . imported "SCOTT"."DEPT"                              5.953 KB       5 rows
. . imported "SCOTT"."EMP"                               8.578 KB      14 rows
. . imported "SCOTT"."SALGRADE"                          5.937 KB      10 rows
. . imported "SCOTT"."BONUS"                                 0 KB       0 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/COMMENT
Processing object type TABLE_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SCOTT"."SYS_IMPORT_FULL_01" successfully completed at 12:50:22

原文地址:https://www.cnblogs.com/alen-liu-sz/p/12975734.html