如何用oracle imp impdbdb和expdb导出数据要花多长时间

博客访问: 69420
博文数量: 25
注册时间:
ITPUB论坛APP
ITPUB论坛APP
APP发帖 享双倍积分
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: Linux
1、环境准备:(1)检查有无建立expdp目录SQL>sqlplus / as sysdbaSQL>desc dba_Name&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Null?&&& Type&----------------------------------------- -------- ----------------------------&OWNER&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& NOT NULL VARCHAR2(30)&DIRECTORY_NAME&&&&&&&&&&&&&&&&&&&&&&&&&&& NOT NULL VARCHAR2(30)&DIRECTORY_PATH&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& VARCHAR2(4000)SQL>set linesize 200SQL>col owner format a8;SQL>col DIRECTORY_NAME format a30SQL>col DIRECTORY_PATH format a70SQL>select * from dba_OWNER DIRECTORY_NAME&&&&&&&&&&& DIRECTORY_PATH----- ------------------------- ----------------------------------------------------------------------SYS&& LOG_DIR&&&&&&&&&&&&&&&&&& /home/data/file/realSYS&& IDR_DIR&&&&&&&&&&&&&&&&&& /Oracle/app/diag/rdbms/oradb/oradb/irSYS&& SUBDIR&&&&&&&&&&&&&&&&&&& /Oracle/app/product/11.1.0/db/demo/schema/order_entry//2002/SepSYS&& XMLDIR&&&&&&&&&&&&&&&&&&& /Oracle/app/product/11.1.0/db/demo/schema/order_entry/SYS&& LOG_FILE_DIR&&&&&&&&&&&&& /Oracle/app/product/11.1.0/db/demo/schema/log/SYS&& DATA_FILE_DIR&&&&&&&&&&&& /Oracle/app/product/11.1.0/db/demo/schema/sales_history/SYS&& MEDIA_DIR&&&&&&&&&&&&&&&& /Oracle/app/product/11.1.0/db/demo/schema/product_media/SYS&& AUDIT_DIR&&&&&&&&&&&&&&&& /tmp/SYS&& DATA_PUMP_DIR&&&&&&&&&&&& /Oracle/app/admin/oradb/dpdump/SYS&& ORACLE_OCM_CONFIG_DIR&&&& /Oracle/app/product/11.1.0/db/ccr/state10 rows selected.结果:没有expdp目录。(2)建立目录,并赋给用户权限。[oracle@anpc ~]$ mkdir /Oracle/expdpSQL>sqlplus / as sysdbaSQL> create or replace directory expdp_dir as '/Oracle/expdp';Directory created.SQL> grant read,write on directory expdp_Grant succeeded.SQL> select * from dba_directories where DIRECTORY_NAME='EXPDP_DIR';OWNER DIRECTORY_NAME&&&&&&&&&&& DIRECTORY_PATH----- ------------------------- ----------------------------------------------------------------------SYS&& EXPDP_DIR&&&&&&&&&&&&&&&& /Oracle/expdp2、脚本测试:(1)导出备份脚本如下:[oracle@anpc ~]$vi expdptest.sh#!/bin/bash#expdp backup database#mady by andyf_name=`date +%Y%m%d`export f_namedate +"%Y-%m-%d %H:%M:%S"expdp system/system@oradb dumpfile=scott_expdp_%U_$f_name.dmp logfile=scott_expdp_$f_name.log directory=expdp_dir SCHEMAS=scott filesize=500m parallel=4date +"%Y-%m-%d %H:%M:%S"[oracle@anpc ~]$chmod +x expdptest.sh[oracle@anpc ~]$./expdptest.sh(2)手动执行导出脚本测试。[oracle@anpc ~]$ ./expdptest.sh
14:39:24Export: Release 11.1.0.6.0 - 64bit Production on Wednesday, 01 June, :24Copyright (c) , Oracle.& All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsStarting "SYSTEM"."SYS_EXPORT_SCHEMA_01":& system/********@oradb dumpfile=scott_expdp_%U_.dmp logfile=scott_expdp_.log directory=expdp_dir SCHEMAS=scott filesize=500m parallel=4 Estimate in progress using BLOCKS method...Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATATotal estimation using BLOCKS method: 256 KB. . exported "SCOTT"."DEPT"&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 5.937 KB&&&&&& 4 rowsProcessing object type SCHEMA_EXPORT/USER. . exported "SCOTT"."EMP"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 8.570 KB&&&&& 14 rows. . exported "SCOTT"."SALGRADE"&&&&&&&&&&&&&&&&&&&&&&&&& 5.867 KB&&&&&& 5 rows. . exported "SCOTT"."TEST"&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 5.531 KB&&&&&& 9 rows. . exported "SCOTT"."BONUS"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0 KB&&&&&& 0 rowsProcessing object type SCHEMA_EXPORT/ROLE_GRANTProcessing object type SCHEMA_EXPORT/DEFAULT_ROLEProcessing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMAProcessing object type SCHEMA_EXPORT/TABLE/TABLEProcessing object type SCHEMA_EXPORT/TABLE/INDEX/INDEXProcessing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINTProcessing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICSProcessing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINTProcessing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICSProcessing object type SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMAMaster table "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded******************************************************************************Dump file set for SYSTEM.SYS_EXPORT_SCHEMA_01 is:& /Oracle/expdp/scott_expdp_01_.dmp& /Oracle/expdp/scott_expdp_02_.dmpJob "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 14:39:33 14:39:33(4)导入脚本如下:[oracle@anpc ~]$vi impdptest.sh#!/bin/bash#impdp into database#mady by andyf_name=`date +%Y%m%d`export f_namedate +"%Y-%m-%d %H:%M:%S"impdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_01_$f_name.dmp,scott_expdp_02_$f_name.dmp logfile=scott_impdp_$f_name.log &remap_schema=scott:scott date +"%Y-%m-%d %H:%M:%S"[oracle@anpc ~]$chmod +x impdptest.sh(5)执行导入脚本:[oracle@anpc ~]$./impdptest.sh 16:07:53Import: Release 11.1.0.6.0 - 64bit Production on Wednesday, 01 June, :53Copyright (c) , Oracle.& All rights reserved.Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsMaster table "SYSTEM"."SYS_IMPORT_FULL_01" successfully loaded/unloadedStarting "SYSTEM"."SYS_IMPORT_FULL_01":& system/********@oradb directory=expdp_dir dumpfile=scott_expdp_01_.dmp,scott_expdp_02_.dmp logfile=scott_impdp_.log remap_schema=scott:scott Processing object type SCHEMA_EXPORT/USERProcessing object type SCHEMA_EXPORT/ROLE_GRANTProcessing object type SCHEMA_EXPORT/DEFAULT_ROLEProcessing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMAProcessing object type SCHEMA_EXPORT/TABLE/TABLEProcessing object type SCHEMA_EXPORT/TABLE/TABLE_DATA. . imported "SCOTT"."DEPT"&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 5.937 KB&&&&&& 4 rows. . imported "SCOTT"."EMP"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 8.570 KB&&&&& 14 rows. . imported "SCOTT"."SALGRADE"&&&&&&&&&&&&&&&&&&&&&&&&& 5.867 KB&&&&&& 5 rows. . imported "SCOTT"."TEST"&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 5.531 KB&&&&&& 9 rows. . imported "SCOTT"."BONUS"&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 0 KB&&&&&& 0 rowsProcessing object type SCHEMA_EXPORT/TABLE/INDEX/INDEXProcessing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINTProcessing object type SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICSProcessing object type SCHEMA_EXPORT/TABLE/CONSTRAINT/REF_CONSTRAINTProcessing object type SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICSProcessing object type SCHEMA_EXPORT/POST_SCHEMA/PROCACT_SCHEMAJob "SYSTEM"."SYS_IMPORT_FULL_01" successfully completed at 16:07:56 16:07:57测试登陆是否成功:[oracle@anpc ~]$ sqlplus scott/scott@oradb3、expdp/impdp导入导出模式:(1)全库导出导入模式expdp system/system@oradb directory=expdp_dir dumpfile=expdp_fulldb_$f_name.dmp& full=yimpdp system/system@oradb directory=expdp_dir dumpfile=expdp_fulldb_$f_name.dmp& full=y(2)用户导出模式expdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_%U_$f_name.dmp SCHEMAS=scottimpdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_01_$f_name.dmp,scott_expdp_02_$f_name.dmp&& remap_schema=scott:scott (3)表导出模式expdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_%U_$f_name.dmp tables=scott.emp, scott.dept注:使用query条件的语句时最好采用parfile方式可以按条件导出数据。impdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_%U_$f_name.dmp tables=scott.emp, scott.deptimpdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_%U_$f_name.dmp schemas=scott table_exists_action=append &注:追加数据。(4)表空间导出模式expdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_%U_$f_name.dmp tablespaces=tbs1,tbs2impdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_01_$f_name.dmp tablespaces=tbs1,tbs2(5)可移动表空间导出模式expdp system/system@oradb directory=expdp_dir dumpfile=scott_expdp_%U_$f_name.dmp transport_tablespaces=tbs1注:expdp -help可以查看到所有expdp的参数。 &&& impdp -help可以查看到所有impdp的参数。常见参数:DIRECTORY:指定转储文件和日志文件所在的目录DUMPFILE:用于指定转储文件的名称,默认名称为expdat.dmpLOGFILE:指定导出日志文件文件的名称,默认名称为export.logSCHEMAS:该方案用于指定执行方案模式导出,默认为当前用户方案.TABLESPACES:指定要导出表空间列表TABLES:指定表模式导出.TABLES=[schema_name.]table_name[:partition_name][,…]CONTENT={ALL | DATA_ONLY | METADATA_ONLY}& ALL将导出对象定义及其所有数据,DATA_ONLY只导出对象数据,METADATA_ONLY只导出对象定义。EXCLUDE=object_type[:name_clause] [,….]& 排除的对象类型及相关对象。INCLUDE=object_type[:name_clause] [,… ]& 包含的对象类型及相关对象。不能和EXCLUDE同时用。FILESIZE:指定导出文件的最大尺寸,默认为0,(表示文件尺寸没有限制)。PARALLEL:指定执行导出操作的并行进程个数,默认值为1。
阅读(4045) | 评论(0) | 转发(0) |
相关热门文章
给主人留下些什么吧!~~
expdp/impdp的使用方法这篇文章已被推荐到圈子中。
请登录后评论。博客访问: 1636161
博文数量: 407
博客积分: 4177
博客等级: 上校
技术积分: 4771
注册时间:
网名:东东堂.现任职于深圳某公司DBA,主要负责公司的数据库管理,部署,排错,备份恢复和性能调整等各种数据库相关工作。多年的数据库管理经历,积累了丰富的数据库运维经验.主要的技术方向:ORACLE,MySQL,Timesten,Linux以及服务器,存储等相关领域.
APP发帖 享双倍积分
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: Oracle
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& EXP/IMP和EXPDP/IMPDP的区别
&&&&&& EXPDP/IMPDP是10G以后的一种新的数据导入导出方式,也称为数据泵。相比于传统的EXP/IMP的方式有了很大的不同.
&&&& EXP/IMP产生的文件格式和EXPDP/IMPDP并不兼容,虽然文件名字都是DMP扩展文件。不能用EXP导出的的文件用IMPDP导入,反之则一样.
&&& EXP/IMP的是客户机的工作模式,由EXP/IMP指定连接串,连接到相应的ORACLE数据库,然后在ORACLE数据库生成一个相应的前台服务器成进程来完成各种请求,所以IMP/EXP可以进行远程导入导出.EXPDP/IMPDP直接在ORACLE数据库生成一个后台进程来完成相应的任务.
&& EXP/IMP通过数据字典来获取相应的对像信息,并且通过select来返回对像中的所有数据,在EXP的时会进行全表扫描,也相当于做了一次块的检查.在exp的时候,有可能会得到表数据不一致的情况,可以通过consistent来指定,那样可能会导致undo表空间变得非常大。EXPDP主要是通过执行DBMS_METADATA的包来获取对像的相应信息,而且直接是通过拷贝相应数据文件块的方式,所以效率要高得多.
&& EXPDP/IMPDP还有很多迷人的特性,比如可以过相应的网络导出导入,在大文件操作时候,就不要生成中间文件了.还有job装态,表空间REMAP,并行等.但是expdp/impdp在使用的时候要创建DIRECTORY。数据量很小的时候一般还是喜欢使用传统有EXP/IMP方式样.
阅读(10666) | 评论(0) | 转发(1) |
相关热门文章
给主人留下些什么吧!~~
请登录后评论。

我要回帖

更多关于 oracle expdb 的文章

 

随机推荐