数据泵方式到出入数据

预置条件:数据库中存在数据库 :user001
问题:想讲数据库USER001的数据导入到一个新的用户下USER002
实现方案:使用ORACLE数据库中的数据泵
首先创建USER002的表空间
脚本如下:
CREATE TABLESPACE user002
DATAFILE '/opt/oracle/oradata/user002.dbf' SIZE 10M REUSE
AUTOEXTEND ON NEXT 1M MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL;


创建用户:
-- Create the user
create user USER002
identified by ""
default tablespace USER002
temporary tablespace TEMP
profile DEFAULT
password expire;
-- Grant/Revoke role privileges
grant connect to USER002;
grant dba to USER002;
grant resource to USER002;
-- Grant/Revoke system privileges
grant alter any table to USER002 with admin option;
grant create any table to USER002 with admin option;
grant create any view to USER002 with admin option;
grant create public database link to USER002;
grant drop any table to USER002 with admin option;
grant drop any view to USER002 with admin option;
grant drop public database link to USER002;
grant select any table to USER002 with admin option;
grant unlimited tablespace to USER002 with admin option;


然后使用IMPDP 导出数据文件

expdp scott/ scott directory=expdir dumpfile=user001.dmp schemas=user001;

在此之前要做两件事情 第一件事情就是要创建 directory=expdir 中的expdir目录 这个目录是用来存放导入导出文件和导出导出日志文件的。第二件事情就是给导入导出用户设置读写这个临时文件的权限:

create or replace directory expdir as '/opt/oracle/impdir';
grant read,write on directory expdir to manager (导出用户权限)
grant read,write on directory expdirdir to user002 (导入用户权限)

注意:如果opt/oracle/expimpdir这个目录没有必须提前新建 (这个目录是可以随便指定的)

create or replace directory expdir as 'opt/oracle/expimpdir:'; 我们可以把expdir 理解为一个变量名 create or replace directory expdir as 'opt/oracle/expimpdir:'; 其实就是给这个变量名赋值。

查询变量名的方法:select * from dba_directories

然后就是导入操作 导入操作执行

Impdp scott/scott directory=expdir dumpfile=user001.dmp remap_schema=user001:user002;(从什么用户覆盖到什么用户)


利用数据泵做导入导出操作效率很高 大家可以再有空的时间多研究下!如果大家有不明白的地方可以询问我。一起交流
impdp ireadtest/ireadtest directory=

noseid:lKF14183


D:\app\sKF13320\product\11.1.0\client_2\network\admin


ALTER TABLESPACE ireadrpt
RENAME DATAFILE '/opt/oracle/oradata/user002.dbf'
TO '/export/home/user002.dbf';


expdp manager/ mread directory=expdir dumpfile=manager729.dmp schemas=manager;(导出什么用户)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值