Oracle10g导入导出工具
一, 工具简介
服务器端使用。
Expdp使用示例:
2. 创建directory对象
[oracle@localhost dump]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 12 17:11:09 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba; Connected.
SQL> create or replace directory dump_dir as '/home/oracle/dump'; SQL>grant read,write on directory dump_dir to claim SQL>exit;
3. 执行导出(导出方案)
[oracle@localhost ~]$ expdp account/account directory=dump_dir dumpfile=schema.dmp schemas= account parallel=4
参数说明:account / account连接数据库用户名/密码
Directory 用于指定转储文件和日志文件所在位置,即第2步定义的
dump_dir(名称由用户命名)。
Dumpfile 用于指定转储文件的名称
Schemas 用于指定执行方案模式导出,默认为当前用户方案
Parallel 用于指定导出操作的并行进程个数,默认为1,通过执行并行导出操作,可以加快导出速度。
导出过程如下:
opyright (c) 2003, 2005, Oracle. All rights reserved. ;;;
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options Starting "ACCOUNT"."SYS_EXPORT_SCHEMA_01": account/******** directory=dump_dir dumpfile=schema.dmp schemas=account parallel=4 Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 5.519 GB Processing object type SCHEMA_EXPORT/USER
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/DB_LINK
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE 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/FUNCTION/FUNCTION Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE 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/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT Processing object type
SCHEMA_EXPORT/TABLE/INDEX/FUNCTIONAL_AND_BITMAP/INDEX Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS . . exported "ACCOUNT"."WFLOG" 205.2 MB 711777 rows
. . exported "ACCOUNT"."SWFLOG" 198.3 MB 532619 rows
. . exported "ACCOUNT"."ACCREPORTDATA" 172.4 MB 3120753 rows
. . exported "ACCOUNT"."PRPJPAYREFREC" 156.5 MB 444256 rows
省略
*****************************************************************************
Dump file set for ACCOUNT.SYS_EXPORT_SCHEMA_01 is: /home/oracle/dump/schema.dmp
Job "ACCOUNT"."SYS_EXPORT_SCHEMA_01" successfully completed at 17:28:15 Impdp的使用与expdp类似
如:impdp account/account directory=dump_dir dumpfile=schema.dmp schemas=account parallel=4
Expdp/impdp工具自带了很多执行时使用的参数,具体使用时请查阅相关资料,此处不做详细说明。
三, 常见问题处理:
第一次登录oracle服务器执行expdp操作时,可能会出现如下错误
expdp account/account directory=dump_dir dumpfile=schema.dmp schemas= account parallel=4
Export: Release 10.2.0.4.0 - Production on Wednesday, 26 May, 2010 11:02:10
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options ORA-39006: internal error
ORA-39213: Metadata processing is not available 问题解决方法:
以dba用户登录数据库,并执行exec dbms_metadata_util.load_stylesheets; [oracle@localhost dump]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 12 17:11:09 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba; Connected.
SQL> exec dbms_metadata_util.load_stylesheets; SQL>exit
四, 性能比较
为了比较exp与expdp工具的执行速度,在数据库服务器做如下实验, 以导出10.0.105.11数据库account用户的方案为例,account用户的方案大小约为5.3G,在数据库服务器上执行如下操作: 1. exp account/account owner=account buffer=102476800 file=/home/oracle/dump/0312.dmp 测试结果:耗时16分钟 2. expdp account/account directory=dump_dir dumpfile=schema.dmp schemas=account parallel=4 测试结果:耗时4分钟 查阅相关网上资料,网友做的这两种工具的一些性能测试实验结果,impdp比ipm效率高几十倍。根据oracle的官方说明,impdp是数据泵技术最杰出的地方,可以说明expdp/impdp工具比传统的exp/imp工具在执行效率上有了很大的提高。所以推荐大家使用expdp/impdp工具。
一, 工具简介
Oracle数据库传统的导入导出使用imp/emp工具完成。从oracle10g开始,oracle不仅保留了原有的imp/emp工具,还提供了数据泵导出导入工具expdp/impdp工具,xpdp/impdp工具的速度由于imp/emp工具,oracle建议使用数据泵导入导出工具。
需要注意:
1. exp和imp是客户端的工具程序,它们既可以在客户端使用,也可以在服务器端使用。
2. expdp和impdp是服务器端的工具程序,只能在oracle服务器端执行。 3. imp工具只适用于exp导出文件,不适用于expdp导出文件。同理impdp工具也一样。即二者的导出文件是不兼容的。
数据泵导出类型有四种模式
- 导出表(一张或者多张)
- 导出方案
- 导出表空间
- 导出数据库
Expdp使用示例:
使用oracle用户登录数据库,
1. 创建导出文件要存放的目录
[oracle@localhost ~]$ mkdir dump2. 创建directory对象
[oracle@localhost dump]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 12 17:11:09 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba; Connected.
SQL> create or replace directory dump_dir as '/home/oracle/dump'; SQL>grant read,write on directory dump_dir to claim SQL>exit;
3. 执行导出(导出方案)
[oracle@localhost ~]$ expdp account/account directory=dump_dir dumpfile=schema.dmp schemas= account parallel=4
参数说明:account / account连接数据库用户名/密码
Directory 用于指定转储文件和日志文件所在位置,即第2步定义的
dump_dir(名称由用户命名)。
Dumpfile 用于指定转储文件的名称
Schemas 用于指定执行方案模式导出,默认为当前用户方案
Parallel 用于指定导出操作的并行进程个数,默认为1,通过执行并行导出操作,可以加快导出速度。
导出过程如下:
opyright (c) 2003, 2005, Oracle. All rights reserved. ;;;
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options Starting "ACCOUNT"."SYS_EXPORT_SCHEMA_01": account/******** directory=dump_dir dumpfile=schema.dmp schemas=account parallel=4 Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA Total estimation using BLOCKS method: 5.519 GB Processing object type SCHEMA_EXPORT/USER
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/DB_LINK
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE 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/FUNCTION/FUNCTION Processing object type SCHEMA_EXPORT/PROCEDURE/PROCEDURE 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/PACKAGE/PACKAGE_BODY
Processing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINT Processing object type
SCHEMA_EXPORT/TABLE/INDEX/FUNCTIONAL_AND_BITMAP/INDEX Processing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/FUNCTIONAL_AND_BITMAP/INDEX_STATISTICS
Processing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS . . exported "ACCOUNT"."WFLOG" 205.2 MB 711777 rows
. . exported "ACCOUNT"."SWFLOG" 198.3 MB 532619 rows
. . exported "ACCOUNT"."ACCREPORTDATA" 172.4 MB 3120753 rows
. . exported "ACCOUNT"."PRPJPAYREFREC" 156.5 MB 444256 rows
省略
*****************************************************************************
Dump file set for ACCOUNT.SYS_EXPORT_SCHEMA_01 is: /home/oracle/dump/schema.dmp
Job "ACCOUNT"."SYS_EXPORT_SCHEMA_01" successfully completed at 17:28:15 Impdp的使用与expdp类似
如:impdp account/account directory=dump_dir dumpfile=schema.dmp schemas=account parallel=4
Expdp/impdp工具自带了很多执行时使用的参数,具体使用时请查阅相关资料,此处不做详细说明。
三, 常见问题处理:
第一次登录oracle服务器执行expdp操作时,可能会出现如下错误
expdp account/account directory=dump_dir dumpfile=schema.dmp schemas= account parallel=4
Export: Release 10.2.0.4.0 - Production on Wednesday, 26 May, 2010 11:02:10
Copyright (c) 2003, 2007, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options ORA-39006: internal error
ORA-39213: Metadata processing is not available 问题解决方法:
以dba用户登录数据库,并执行exec dbms_metadata_util.load_stylesheets; [oracle@localhost dump]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 12 17:11:09 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn / as sysdba; Connected.
SQL> exec dbms_metadata_util.load_stylesheets; SQL>exit
四, 性能比较
为了比较exp与expdp工具的执行速度,在数据库服务器做如下实验, 以导出10.0.105.11数据库account用户的方案为例,account用户的方案大小约为5.3G,在数据库服务器上执行如下操作: 1. exp account/account owner=account buffer=102476800 file=/home/oracle/dump/0312.dmp 测试结果:耗时16分钟 2. expdp account/account directory=dump_dir dumpfile=schema.dmp schemas=account parallel=4 测试结果:耗时4分钟 查阅相关网上资料,网友做的这两种工具的一些性能测试实验结果,impdp比ipm效率高几十倍。根据oracle的官方说明,impdp是数据泵技术最杰出的地方,可以说明expdp/impdp工具比传统的exp/imp工具在执行效率上有了很大的提高。所以推荐大家使用expdp/impdp工具。