全哥

不断学习,努力超越自己.

导航

expdp的常用用法

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

查看创建的目录: select * from dba_directories;

本文来自德仔工作室 http://www.dezai.cn/Channel/Web/ArticleShow.aspx?AI=59356&CI=4

 

posted on 2010-03-08 15:30  全哥  阅读(1172)  评论(0编辑  收藏  举报