expdp / impdp 例子

本文详细记录了使用Oracle数据库的expdp和impdp命令进行数据导出与导入的过程。从创建目录、权限配置,到具体操作步骤均有详尽描述,并提供了实际执行的例子。过程中涉及了多个大型表的数据迁移。

本次导出,导入分别花时5 分钟及1小时18分 ,大小为9G左右dmp文件。

1.  准备工作,需要在源库及目标库建立 directory 作为dmp文件的目录,当然源库和目标库的directory 及实际
路径可以不一样 。这里为方便,取名称一致 。 以下命令分别在源库及目标库上运行。

SQL>create directory dmpdir as  '/data1/dmpfiledir';  
SQL>grant read,write on directory  dmpdir   to dfms ;   其中DFMS是要导出导入的schema .


2.    在源库上导出dfms schema的dmp文件,拷贝到目标库对应的目录下,执行import .

$ expdp    system/system#oracle$  directory=dmpdir  dumpfile=dfms.dmp   schemas=dfms  - 源库  
$ impdp    system/system#oracle$  directory=dmpdir  dumpfile=dfms.dmp   schemas=dfms  - 目标库 

 

3. 例子 (源库导出): 

MXPSVDFMSNDB$ls
dmpfiledir


MXPSVDFMSNDB$ expdp system/oracle  directory=dmpdir  dumpfile=dfms.dmp   schemas=dfms
;;;
Export: Release 10.2.0.4.0 - 64bit Production    2009 20:50:42

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
;;;
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining Scoring Engine
and Real Application Testing options
FLASHBACK automatically enabled to preserve database integrity.
Starting "SYSTEM"."SYS_EXPORT_SCHEMA_01":  system/******** directory=dmpdir dumpfile=dfms.dmp schemas=dfms
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 11.91 GB
Processing object type SCHEMA_EXPORT/USER
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
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/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/PACKAGE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/FUNCTION/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PROCEDURE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Processing object type SCHEMA_EXPORT/VIEW/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/JOB
Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMA
. . exported "DFMS"."WIP_D_SN_L6"                        1.005 GB 5076778 rows
. . exported "DFMS"."WIP_D_WO_DETAIL"                    843.1 MB 7408141 rows
. . exported "DFMS"."WIP_D_SN_DETAIL"                    833.5 MB 4800639 rows
. . exported "DFMS"."SYS_D_ERROR_TRACE"                  819.7 MB 6946197 rows
. . exported "DFMS"."WIP_L_ASSY_COMPONENT"               765.0 MB 7083540 rows
. . exported "DFMS"."WIP_D_ASSY_COMPONENT"               765.0 MB 7115784 rows
. . exported "DFMS"."EDIBTO850_DETAIL"                   476.6 MB 2825732 rows
. . exported "DFMS"."LABELS_CONFIG_COMTOSKUATTRBUTE"     429.6 MB 2469428 rows
. . exported "DFMS"."WIP_D_CSN_DETAIL"                   419.9 MB 4461031 rows
. . exported "DFMS"."WIP_D_CSN_MASTER"                   427.5 MB 3855630 rows
. . exported "DFMS"."EDIBTO850_PO1PID"                   287.5 MB 2825949 rows
. . exported "DFMS"."WIP_D_SN_INPUT"                     239.3 MB 5010477 rows
. . exported "DFMS"."WIP_D_STATION_UPH"                  248.4 MB 3087825 rows
. . exported "DFMS"."SAP_L_DOWNLOAD"                     163.6 MB 1499011 rows
. . exported "DFMS"."WIP_D_SN_MASTER"                    91.21 MB  423112 rows
. . exported "DFMS"."ERP_D_SO_DETAIL"                    65.76 MB  449534 rows
. . exported "DFMS"."TST_D_AUTOTEST_PART"                46.19 MB   82151 rows  
.... 
. . exported "DFMS"."WIP_L_BARCODE_RULE_SSN"                 0 KB       0 rows
. . exported "DFMS"."WIP_S_ASSY_BOM"                         0 KB       0 rows
. . exported "DFMS"."WIP_S_ASSY_BOM_TMP"                     0 KB       0 rows
. . exported "DFMS"."WIP_S_ASSY_CONFIG"                      0 KB       0 rows
. . exported "DFMS"."WIP_S_ASSY_CONFIG_TMP"                  0 KB       0 rows
. . exported "DFMS"."WIP_S_DUTY"                             0 KB       0 rows
. . exported "DFMS"."WIP_S_STATION_TYPE"                     0 KB       0 rows
. . exported "DFMS"."WIP_T_TEMP"                             0 KB       0 rows
. . exported "DFMS"."WMS_L_FG_BIN_MASTER"                    0 KB       0 rows
Master table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:
  /data1/dmpfiledir/dfms.dmp
Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 20:55:17


MXPSVDFMSNDB$ls
dfms.dmp  export.log

4. 目标库导入:   

MXPSVDFMSNDB$ impdp system/oracle  directory=dmpdir  dumpfile=dfms.dmp   schemas=dfms
;;;
Import: Release 10.2.0.4.0 - 64bit Production on Friday,  2009 1:54:21

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
;;;
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_SCHEMA_05" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_05":  system/******** directory=dmpdir dumpfile=dfms_all.dmp schemas=dfms
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"DFMS" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/TABLESPACE_QUOTA
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
. . imported "DFMS"."WIP_D_SN_L6"                        1.005 GB 5076778 rows
. . imported "DFMS"."SYS_D_ERROR_TRACE"                  902.3 MB 7740914 rows
. . imported "DFMS"."WIP_D_WO_DETAIL"                    855.8 MB 7519598 rows
. . imported "DFMS"."WIP_D_SN_DETAIL"                    874.7 MB 5037171 rows
. . imported "DFMS"."WIP_L_ASSY_COMPONENT"               801.8 MB 7425769 rows
. . imported "DFMS"."WIP_D_ASSY_COMPONENT"               802.6 MB 7465935 rows
. . imported "DFMS"."EDIBTO850_DETAIL"                   485.2 MB 2876670 rows
. . imported "DFMS"."LABELS_CONFIG_COMTOSKUATTRBUTE"     441.2 MB 2535865 rows
. . imported "DFMS"."WIP_D_CSN_DETAIL"                   440.2 MB 4676843 rows
. . imported "DFMS"."WIP_D_CSN_MASTER"                   448.5 MB 4044398 rows
. . imported "DFMS"."EDIBTO850_PO1PID"                   292.7 MB 2876691 rows
. . imported "DFMS"."WIP_D_SN_INPUT"                     250.6 MB 5246749 rows
. . imported "DFMS"."WIP_D_STATION_UPH"                  260.2 MB 3234874 rows
...... 
. . imported "DFMS"."WIP_S_ASSY_CONFIG_TMP"                  0 KB       0 rows
. . imported "DFMS"."WIP_S_DUTY"                             0 KB       0 rows
. . imported "DFMS"."WIP_S_STATION_TYPE"                     0 KB       0 rows
. . imported "DFMS"."WIP_T_TEMP"                             0 KB       0 rows
. . imported "DFMS"."WMS_L_FG_BIN_MASTER"                    0 KB       0 rows
Processing object type SCHEMA_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
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/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/PACKAGE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/FUNCTION/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
Processing object type SCHEMA_EXPORT/PROCEDURE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/ALTER_PROCEDURE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
Processing object type SCHEMA_EXPORT/VIEW/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type SCHEMA_EXPORT/TABLE/TRIGGER
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMA
Job "SYSTEM"."SYS_IMPORT_SCHEMA_05" completed with 1 error(s) at 03:18:53
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-618315/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/35489/viewspace-618315/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值