expdp、impdp数据泵导出导入数据

1.创建逻辑目录,该命令并不会创建正在的目录(请先创建真正的目录),以system管理员创建逻辑目录。

sql>sqlplus system/system@tfds as sysdba

sql>create directory dump_dir as 'd:\expdb';

2.查看管理员目录(同时查看操作系统是否创建了该目录,oracle并不会关心是否创建了该目录,如果目录不存在,则会出错)

sql>select * from dba_directories;

3.给需要操作数据导入,导出的用户指定该目录的操作权限,最好以system管理员赋予。

sql>grant read,write on directory dump_dir to tfds;

sql>grant read,write on directory dump_dir to tfdspub;

备注:tfds,tfdspub是需要导入,导出数据,操作数据dump_dir目录的用户

4.expdp导出数据

1)导出用户
expdp scott/tiger@orcl schemas=scott dumpfile=expdp.dmp directory=dump_dir;

2)导出表
expdp scott/tiger@orcl tables=emp,dept dumpfile=expdp.dmp directory=dump_dir;

3)按查询条件导
expdp scott/tiger@orcl directory=dump_dir dumpfile=expdp.dmp tables=empquery='where deptno=20';

4)按表空间导
expdp system/manager@orcl directory=dump_dir dumpfile=tablespace.dmptablespaces=temp,example;

5)导整个数据库
expdp system/manager@orcl directory=dump_dir dumpfile=full.dmp full=y;

以tfds,tfdspub用户为例,导出两个用户的数据

expdp system/system@tfds dirrctory=dump_dir dumpfile=tfds.dmp schemas=(tfds,tfdspub);

5.用impdp导入数据

1)导入用户(从用户scott导入到用户scott)
impdp scott/tiger@orcl directory=dump_dir dumpfile=expdp.dmp schemas=scott;

2)导入表(从scott用户中把表dept和emp导入到system用户中)
impdp system/manager@orcl directory=dump_dir dumpfile=expdp.dmptables=scott.dept,scott.emp remap_schema=scott:system;

3)导入表空间
impdp system/manager@orcl directory=dump_dir dumpfile=tablespace.dmp tablespaces=example;

4)导入数据库
impdb system/manager@orcl directory=dump_dir dumpfile=full.dmp full=y;

5)追加数据
impdp system/manager@orcl directory=dump_dir dumpfile=expdp.dmp schemas=systemtable_exists_action

以tfds,tfdspub为例,导入两个用户的数据

impdp system/system@tfds directory=dump_dir dumpfile=tfds.dmp schemas=(tfds,tfdspub);

猜你喜欢

转载自www.cnblogs.com/zhangshuaihui/p/11441713.html