oracle服务端导出/导入方式expdp/impdp

1. expdp导出步骤

1.1 用sys管理员登录sqlplus

[root@hxjk_test_mysql_redis_file oracle]# sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 21 21:49:35 2018

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Enter user-name: orcl
Enter password: 

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> 
View Code

创建逻辑目录;

SQL> create directory BACKDIR as '/opt/oracle/oradata/orcl/';

Directory created.
View Code

查看

SQL> select * from dba_directories;

OWNER                   DIRECTORY_NAME
------------------------------ ------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
SYS                   XMLDIR
/ade/b/2125410156/oracle/rdbms/xml

SYS                   BACKDIR
/opt/oracle/oradata/orcl/

SYS                   DATA_PUMP_DIR
/opt/oracle/admin/orcl/dpdump/


OWNER                   DIRECTORY_NAME
------------------------------ ------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
SYS                   ORACLE_OCM_CONFIG_DIR
/opt/oracle/product/11.2.0/db_1/ccr/state
View Code

1.2 用expdp导出dmp,有五种导出方式:

第一种:“full=y”,全量导出数据库;

expdp carloan/carloan@192.168.40.69:1521/orcl dumpfile=carloan_20181121.dmp directory=backdir full=y logfile=carloan_20181121.log;

carloan_20181121.log日志文件内容如下,会导出整个库内所有的表空间:

;;; 
Export: Release 11.2.0.1.0 - Production on Wed Nov 21 21:35:44 2018

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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "CARLOAN"."SYS_EXPORT_FULL_01":  carloan/********@192.168.40.64:1521/orcl dumpfile=carloan_20181121.dmp directory=backdir full=y logfile=carloan_20181121.log 
Estimate in progress using BLOCKS method...
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 592.4 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/TYPE_SPEC
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PRE_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/PROCOBJ
Processing object type DATABASE_EXPORT/SYSTEM_PROCOBJACT/POST_SYSTEM_ACTIONS/PROCACT_SYSTEM
Processing object type DATABASE_EXPORT/SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TABLE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/PRE_TABLE_ACTION
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/CONSTRAINT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE/PACKAGE_SPEC
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/FUNCTION
Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/PROCEDURE
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/FUNCTION/ALTER_FUNCTION
Processing object type DATABASE_EXPORT/SCHEMA/PROCEDURE/ALTER_PROCEDURE
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/VIEW
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/GRANT/OWNER_GRANT/OBJECT_GRANT
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/COMMENT
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/CONSTRAINT/REF_CONSTRAINT
Processing object type DATABASE_EXPORT/SCHEMA/PACKAGE_BODIES/PACKAGE/PACKAGE_BODY
Processing object type DATABASE_EXPORT/SCHEMA/TYPE/TYPE_BODY
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/FUNCTIONAL_AND_BITMAP/INDEX
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_TABLE_ACTION
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/TRIGGER
Processing object type DATABASE_EXPORT/SCHEMA/VIEW/TRIGGER
Processing object type DATABASE_EXPORT/SCHEMA/EVENT/TRIGGER
Processing object type DATABASE_EXPORT/SCHEMA/MATERIALIZED_VIEW
Processing object type DATABASE_EXPORT/SCHEMA/JOB
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_INSTANCE/PROCACT_INSTANCE
Processing object type DATABASE_EXPORT/SCHEMA/TABLE/POST_INSTANCE/PROCDEPOBJ
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCOBJ
Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
Processing object type DATABASE_EXPORT/AUDIT
. . exported "ORCL"."MA_ASSET_RELATED_DETAIL"            104.7 MB 2743778 rows
. . exported "MA_HXPH0709"."MA_ASSET_RELATED_DETAIL"     52.51 MB 1375642 rows
. . exported "CARLOAN"."BASE_CITYS"                      39.89 MB  713987 rows

……

Master table "CARLOAN"."SYS_EXPORT_FULL_01" successfully loaded/unloaded
******************************************************************************
Dump file set for CARLOAN.SYS_EXPORT_FULL_01 is:
  /opt/oracle/oradata/orcl/carloan_20181121.dmp
Job "CARLOAN"."SYS_EXPORT_FULL_01" successfully completed at 21:41:11
View Code

第二种:schemas按用户导出;

expdp carloan/carloan@192.168.40.64:1521/orcl schemas=carloan dumpfile=carloan_20181121_2.dmp directory=backdir logfile=carloan_20181121_2.log;

carloan_20181121_2.log,会导出用户carloan默认表空间carloan的数据。

;;; 
Export: Release 11.2.0.1.0 - Production on Wed Nov 21 21:48:17 2018

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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "CARLOAN"."SYS_EXPORT_SCHEMA_01":  carloan/********@192.168.40.64:1521/orcl schemas=carloan dumpfile=carloan_20181121_2.dmp directory=backdir logfile=carloan_20181121_2.log 
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 63.06 MB
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/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
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/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE
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/TABLE/STATISTICS/TABLE_STATISTICS
Processing object type SCHEMA_EXPORT/JOB
. . exported "CARLOAN"."BASE_CITYS"                      39.89 MB  713987 rows
. . exported "CARLOAN"."ACT_EVT_LOG"                     2.036 MB    5590 rows
. . exported "CARLOAN"."BASE_CARS"                       1.758 MB   24488 rows
. . exported "CARLOAN"."MSG_INTERFACE_LOG"               1.851 MB    1869 rows
. . exported "CARLOAN"."BASE_CAR_TYPE"                   1.224 MB   12244 rows
. . exported "CARLOAN"."ACT_HI_ACTINST"                  112.1 KB     833 rows
. . exported "CARLOAN"."ACT_HI_COMMENT"                  49.88 KB     643 rows

……

Master table "CARLOAN"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for CARLOAN.SYS_EXPORT_SCHEMA_01 is:
  /opt/oracle/oradata/orcl/carloan_20181121_2.dmp
Job "CARLOAN"."SYS_EXPORT_SCHEMA_01" successfully completed at 21:48:50
View Code

第三种:按表空间导出;

expdp carloan/carloan@192.168.40.64:1521/orcl TABLESPACES=carloan dumpfile=carloan_20181121_3.dmp directory=backdir logfile=carloan_20181121_3.log;

carloan_20181121_3.log内容如下:

;;; 
Export: Release 11.2.0.1.0 - Production on Wed Nov 21 22:08:43 2018

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 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "CARLOAN"."SYS_EXPORT_TABLESPACE_01":  carloan/********@192.168.40.64:1521/orcl TABLESPACES=carloan dumpfile=carloan_20181121_3.dmp directory=backdir logfile=carloan_20181121_3.log 
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 63.06 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/STATISTICS/TABLE_STATISTICS
. . exported "CARLOAN"."BASE_CITYS"                      39.89 MB  713987 rows
. . exported "CARLOAN"."ACT_EVT_LOG"                     2.036 MB    5590 rows
. . exported "CARLOAN"."BASE_CARS"                       1.758 MB   24488 rows
. . exported "CARLOAN"."MSG_INTERFACE_LOG"               1.851 MB    1869 rows

……

Master table "CARLOAN"."SYS_EXPORT_TABLESPACE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for CARLOAN.SYS_EXPORT_TABLESPACE_01 is:
  /opt/oracle/oradata/orcl/carloan_20181121_3.dmp
Job "CARLOAN"."SYS_EXPORT_TABLESPACE_01" successfully completed at 22:09:05
View Code

第四种:导出表;

expdp carloan/carloan@192.168.40.64:1521/orcl TABLES=ACT_RU_TASK dumpfile=carloan_20181121_4.dmp directory=backdir logfile=carloan_20181121_4.log;

第五种:按查询条件导;

2.impdp导入步骤

如果不是同一台服务器,需要先将上面的dmp文件下载到目标服务器上,建立逻辑目录,放入逻辑目录下

用impdp命令导入,下面介绍两种

第一种同名用户导入,从用户A导入到用户A;

impdp carloan/carloan@192.168.40.64:1521/orcl directory=backdir dumpfile='carloan_20181113144951.dmp' schemas=carlo

第二种. 从carloan用户中把表ACT_GE_BYTEARRAY 导入到carloan2用户中;

impdp carloan2/carloan2@192.168.40.64:1521/orcl tables=carloan.ACT_GE_BYTEARRAY remap_schema=carloan:carloan2 directory=backdir dumpfile=carloan_20181113144951.dmp;

转载于:https://www.cnblogs.com/gexiaoshan/p/9998372.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值