expdp/EXP

来源:互联网 发布:梦觉教游泳知乎 编辑:程序博客网 时间:2024/05/21 10:53

expdp是 oracle 10g提供的一个代替exp的工具,不论从速度还是功能上来讲,相对于exp来说都是一个飞跃。

1. 执行expdp之前要先创建directory对象,如:

CONNECT system/manager

CREATE OR REPLACE DIRECTORY expdir AS ‘d:\exp’;

GRANT read,write ON DIRECTORY expdir TO public;

2. 常见用法:

2.1 导出scott整个schema

expdp scott/tiger@bright parfile=c:\exp.par –默认导出登陆账号的schema

exp.par内容:

DIRECTORY=expdir

DUMPFILE=scott_full.dmp

LOGFILE=scott_full.log或者:

expdp system/oracle@bright parfile=c:\exp.par  –其他账号登陆,在参数中指定schemas

exp.par内容:

DIRECTORY=expdir

DUMPFILE=scott_full.dmp

LOGFILE=scott_full.log

SCHEMAS=SCOTT

2.2 导出scott下的dept,emp表

expdp scott/tiger@bright parfile=c:\exp.par

exp.par内容:

DIRECTORY=expdir

DUMPFILE=scott.dmp

LOGFILE=scott.log

TABLES=DEPT,EMP

2.3 导出scott下除emp之外的表

expdp scott/tiger@bright parfile=c:\exp.par

exp.par内容:

DIRECTORY=expdir

DUMPFILE=scott.dmp

LOGFILE=scott.log

EXCLUDE=TABLE:”=’EMP’”

2.4 导出scott下的存储过程

expdp scott/tiger@bright parfile=c:\exp.par

exp.par内容:

DIRECTORY=expdir

DUMPFILE=scott.dmp

LOGFILE=scott.log

INCLUDE=PROCEDURE

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

expdp scott/tiger@bright parfile=c:\exp.par

DIRECTORY=expdir

DUMPFILE=scott.dmp

LOGFILE=scott.log

INCLUDE=TABLE:”LIKE ‘E%’”   –可以改成 NOT LIKE,就导出不以E开头的表

2.6 带QUERY导出

expdp scott/tiger@bright parfile=c:\exp.parexp.par内容:

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的数据,那么在导入的时候就会出现错误!

situation:

      2个版本客户端,2个版本服务器端,2个版本的dmp文件(也就是导出此文件的客户端),排列组合也有2*2*2=8种

       除去没问题的2种: 本版本间的两种组合(9iclient+9idmp => 9iserver  ;  10gclient+10gdmp => 10gserver) 

a、9iclient+10gdmp => 9iserver 

b、9iclient+10gdmp => 10gserver 

c、10gclient+9idmp => 10gserver 

d、10client+9idmp => 9iserver 

e、9iclient+9idmp => 10gserver 

f、10gclient+10gdmp => 9iserver 

不可以导入成功的2个规则:

1、不同版本的客户端与服务器端是否可以连接的规则:

     规则: 服务器版本需要大于等于客户端版本

     推论:则导入时,d、f将连接不通 ,故不能导入;

2、不同版本的DMP文件是否可以正确导入的规则:

     规则:高版本的dmp(导出时的expclient版本),低版本的client无法识别。

     推论:a、b将导入数据失败

可以导入成功的情况总结:

低版本的dmp文件,无论是高、低版本的客户端,都可以导入到高版本server中。对应c、e

注意:export后是客户端版本,连接到后面是server版本

Export: Release 9.2.0.1.0 - Production on 星期三 2月 20 10:09:55 2008
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options