expdp使用记录

2012-02-08 466 0

工作中需要进行数据迁移,使用expdp做的,做个记录。

expdp是oracle10g中提出来的,比exp的速度高的不是一般,这个是体验过的。和DBA在做数据迁移的时候,开始用的exp,超过半个小时后,我们就忍受不了了,太慢了,就改成了expdb,4分钟,8个G,速度不错吧!

看下我们使用 脚本

   1: expdp dbusername/dbpassword dumpfile=dmpfilename.dmpdirectory=DMPDIRECTORY tables=tablename:partname exclude=index;




 

分析一下
































expdp 
导出命令 dbusername/dbpassword 数据库用户名和密码(注:要有执行expdp命令的权利) dumpfile=dmpfilename.dmp

导出的数据文件 logfile=dmpfilelog.log 导出时的日志文件 directory=DMPDIRECTORY 数据文件的保存位置(需要提前创建) tables=tablename:partname 按表分区导出,tablename是表名,partname是分区名 exclude=index 不导出索引

详细介绍下expdp


1. 执行expdp之前必须创建directory对象,并且分配权限,如:




   connect system/admin



   createor replace directory expdir as'e:dmpfile';



   grantread,writeon directory expdir topublic;




2. 常见用法:(我这里直接用命令行的方式,还有使用配置文件的方式)


2.1 导出scott整个schema




   expdp system/admin@dapengdb DIRECTORY=expdir DUMPFILE=scott_full.dmp LOGFILE=scott_full.log SCHEMAS=SCOTT




配置文件的方式




   expdp system/admin@dapengdb parfile=c:exp.par 




exp.par内容:




   DIRECTORY=expdir



   DUMPFILE=scott_full.dmp



   LOGFILE=scott_full.log



   SCHEMAS=SCOTT




2.2 导出scott下的dept,emp表




   expdp scott/tiger@dapengdb DIRECTORY=expdir DUMPFILE=scott.dmp LOGFILE=scott.log TABLES=DEPT,EMP




2.4 导出scott下的存储过程




   expdp scott/tiger@bright DIRECTORY=expdir DUMPFILE=scott.dmp LOGFILE=scott.log INCLUDE=PROCEDURE




2.5 导出scott下以’E’开头的表



expdp scott/tiger@bright DIRECTORY=expdir DUMPFILE=scott.dmp LOGFILE=scott.log INCLUDE=TABLE:"LIKE'E%'"   –可以改成 NOTLIKE,就导出不以E开头的表




2.6 带QUERY导出

expdp scott/tiger@bright DIRECTORY=expdir DUMPFILE=scott.dmp LOGFILE=scott.log TABLES=EMP,DEPT QUERY=EMP:"where empno >=8000″ QUERY=DEPT:"where deptno >=10 and deptno <=40″




注:处理这样带查询的多表导出,如果多表之间有外健关联,可能需要注意查询条件所筛选的数据是否符合这样的外健约束,比如:EMP中有一栏位是deptno,是关联dept中的主键,如果”where empno >=8000″中得出的deptno=50的话,那么,你的dept的条件”where deptno >=10 and deptno <=40″就不包含deptno=50的数据,那么在导入的时候就会出现错误!
 
摘抄网址:[http://www.dbifan.com/200802/common-usage-of-expdp.html](http://www.dbifan.com/200802/common-usage-of-expdp.html "http://www.dbifan.com/200802/common-usage-of-expdp.html")
原文采用配置文件的方式。

相关文章

15年来的手艺之路:手艺人赵鹏的自述
纪念 Google 25 周年:从搜索引擎到科技巨头的演变之路
1小时编写一个支持七牛上传的 markdown 客户端3(打包发布篇)
1小时编写一个支持七牛上传的 markdown 客户端2(代码优化篇)
1小时编写一个支持七牛上传的 markdown 客户端1(技术实现篇)
从 wordpress 转移到 hexo

Leave a Reply