一、不管导入还有导出都要先创建目录
1、登录plsql
sqlplus/nolog
conn sys/dbwork@orcl
2、创建目录
create directory my_dir as 'd:\yth';--生成目录(必须在指定位置先创建文件夹,名称最好与用户名一致)
yth:是目录名。必须手工创建。
2、增加权限
赋予目录读写权限 Grant read,write on directory my_dir to yth;
yth:导入、导出的用户名
二、导出:
exit,退出plsql。然后操作如下
expdp yth/dcjet@orcl schemas=yth dumpfile=yth.dmp DIRECTORY=my_dir logfile=expdp.log
三、导入:
1、
impdp zjgl/dcjet@orcl directory=myDir dumpfile=zjgl.dmp schemas=zjgl logfile=zjgl.log;
2、
impdp yth/dcjet@orcl directory=my_dir dumpfile=yth.dmp logfile=a.log remap_schema=jzfw_data:yth remap_tablespace=jzfw_data:yth,users:yth,jcfz:yth
---remap_schema:旧用户:目标用户
---remap_tablespace:旧表空间:新表空间(多个的情况用逗号分隔)
下面是成功的例子(my_dir),有时本地只有一个用例不用给@orcl:
impdp zjgl/dcjet@orcl directory=myDir dumpfile=zjgl.dmp schemas=zjgl logfile=zjgl.log;
impdp yth/dcjet directory=my_dir dumpfile=ENTRY.DMP tables=data_ct.entry_head remap_schema=data_ct:yth remap_tablespace=data_center:yth
---tables 指定表名:原表用户.用表名
四、更多导出数据
1)按用户导
expdp scott/tiger@orcl schemas=scott dumpfile=expdp.dmp DIRECTORY=dir logfile=expdp.log
2)并行进程parallel
expdp scott/tiger@orcl directory=dir dumpfile=scott3.dmp parallel=40 job_name=scott3
3)按表名导
expdp scott/tiger@orcl TABLES=emp,dept dumpfile=expdp.dmp DIRECTORY=dir;
4)按查询条件导
expdp scott/tiger@orcl directory=dir dumpfile=expdp.dmp Tables=emp query='WHERE deptno=20';
5)按表空间导
expdp system/manager DIRECTORY=dir DUMPFILE=tablespace.dmp TABLESPACES=temp,example;
6)导整个数据库
expdp system/manager DIRECTORY=dir DUMPFILE=full.dmp FULL=y;
五、更多导入数据
1)导到指定用户下
impdp scott/tiger@orcl DIRECTORY=dir DUMPFILE=expdp.dmp SCHEMAS=scott logfile=impdp.log
2)改变表的owner
impdp system/manager DIRECTORY=dir DUMPFILE=expdp.dmp TABLES=scott.dept REMAP_SCHEMA=scott:system;
3)导入表空间
impdp system/manager DIRECTORY=dir DUMPFILE=tablespace.dmp TABLESPACES=example;
4)导入数据库
impdb system/manager DIRECTORY=dump_dir DUMPFILE=full.dmp FULL=y;
5)追加数据
impdp system/manager DIRECTORY=dir DUMPFILE=expdp.dmp SCHEMAS=system TABLE_EXISTS_ACTION