Oracle利用数据泵impdp导入

IMPDP数据导入

在正式导入数据前,要先确保要导入的用户已存在,如果没有存在,请先用下述命令进行新建用户。

操作流程:

 

一、创建表空间

使用system登录oracle,执行sql

格式: create tablespace 表间名 datafile '数据文件名' size 表空间大小                

create tablespace data_test datafile 'e:oracleoradata est est.dbf' size 2000M;

                (*数据文件名 包含全路径, 表空间大小 2000M 表是 2000兆)

二、创建用户并授权         

格式: create user 用户名 identified by 密码 default tablespace 表空间表;                

create user study identified by study default tablespace data_test;

 (*我们创建一个用户名为 study,密码为 study, 表空间为 madate-这是在上一步建好的.)          

授权给 用户 study     ,执行sql

#给用户逻辑目录读写权限

sql>grant read,write on directory mydata to study;

#给用户表空间权限

sql>grant dba,resource,unlimited tablespace to study;

 

三、impdp导入

命令在cmd或者控制台输入,不是sql语句

写法:

impdp 用户名/密码@ip地址/实例  [属性]

ip地址不写默认就是本地

注释:

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

2)导入表(从scott用户中把表deptemp导入到system用户中)
impdp system/manager@orcl directory=dump_dir dumpfile=expdp.dmp tables=scott.dept,scott.emp remap_schema=scott:system logfile=impdp.log table_exists_action=replace (表空间已存在则替换);

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

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

日常使用的:

 

把用户jcpt中所有的表导入到lyxt用户下

impdp lyxt/lyxt123@127.0.0.1/orcl directory=mydata dumpfile=LY.DMP   remap_schema=jcpt:lyxt logfile=ims20171122.log table_exists_action=replace

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

    以上是日常工作中实际工作中用到的,希望能够给你得到帮助。

仅做交流参考。
原文地址:https://www.cnblogs.com/YoungVin/p/12981597.html