expdp impdp

导出只能在服务器端使用,因为目录只能建在服务器端。

导入可以在客户端导入。

1.conn system;

create directory dump_dir as 'd: estdump';  此步操作前,先去建真实目录。 sql语句并不会创建目录。

select * from dba_directories;

grant read,write on directory dump_dir to scott;--赋予读写目录的权限

命令行下执行:

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;

 

 

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

原文地址:https://www.cnblogs.com/steel-chen/p/7195620.html