# Oracle数据泵(impdp,expdp)导出导入
oracle 10g增加了data pump提供的是一种基于服务器的数据提取和恢复的实用程序,data pump在体系结构和功能上与传统的export和import实用程序相比有了 明显提升。 注意:数据泵文件与传统的exp/imp数据转储文件是不兼容的
1.查看数据库中已创建的directory的两个视图
select * from all_directories;
select * from dba_directories;
2.创建directory
create directory test as '/media/test';
sql> grant read,write on directory test to system;
3.数据泵导出
#单个用户方案导出,用得最多的昌此种方式
expdp [用户名]/[密码]@[主机字符窜] schemas=[用户名] directory=test dumpfile=x.dmp logfile=x.log
#数据库全库导出
expdp [用户名]/[密码]@[主机字符窜] full=y directory=test dumpfile=x.dmp logfile=x.log
#用管理员导入多个用户
expdp [用户名]/[密码]@[主机字符窜] schemas=[用户名],[用户名1],[用户名2]…… directory=test dumpfile=x.dmp logfile=x.log
4.数据泵导入
#单个用户方案导入
impdp [用户名]/[密码]@[主机字符窜] schemas=[用户名] directory=test dumpfile=x.dmp logfile=x.log ignore=y
#数据库全库导入
impdp [用户名]/[密码]@[主机字符窜] full=y directory=test dumpfile=x.dmp logfile=x.log ignore=y
#old用户导入new用户
remap_schema=chwit:chwitnew
# 增加过滤查询条件导出
expdp scott/tiger@back directory=dpdata1 dumpfile=expdp.dmp tables=emp query='where deptno=20';
5.示例:改变表的owner 从scott 用户导入到system 用户下,表空间从 tablespace1 到 tablespace2
impdp system/manager directory=dpdata1 dumpfile=expdp.dmp tables=scott.dept remap_schema=scott:system remap_tablespace=tablespace1:tablespace2