记录一次ORACLE数据库expdp导出与impdp导入

记录一次ORACLE数据库expdp导出与impdp导入

总体思路:
利用expdp从数据源导出dmp文件,利用impdp将dmp文档导入目标数据库
expdp导出步骤:
1.导出文件夹位置: 例如:/home/oracle/data (如果没有需要创建)
2.sqlplus登录(dba用户)
create directory data_dir as ‘/home/oracle/data’;(创建逻辑文件)
select * from dba_directories;(查看命令)
create or replace directory data_dir as ‘/home/oracle/data’;(修改命令)
grant read,write on directory data_dir to task;(用户名);
GRANT EXP_FULL_DATABASE to task;(给用户操作数据库授权,全量导出)
3.执行导出命令"
expdp task/password@ip/orcl schemas=task dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;
impdp导入步骤:
1.重复导出步骤的1,2步骤 即创建 逻辑文件
2.本次将源数据中task用户下的表导入目标数据库的task用户 由于目标数据库没有task用户 所以需要新建
create user task identified by password;(创建用户)
alter user oracle identified by password;(修改密码)
grant dba to task;(给用户授权)
执行impdp导入命令
impdp task/password@ip/orcl schemas=task directory=data_dir dumpfile=expdpdmp logfile=impdp.log;
已上为步骤为:schemas按用户导出
其他导出方式
第一种:“full=y”,全量导出数据库;
expdp user/passwd@orcl dumpfile=expdp.dmp directory=data_dir full=y logfile=expdp.log;
第二种:schemas按用户导出;
expdp user/passwd@orcl schemas=user dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;
第三种:按表空间导出;
expdp sys/passwd@orcl tablespace=tbs1,tbs2 dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;
第四种:导出表;
expdp user/passwd@orcl tables=table1,table2 dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;
第五种:按查询条件导;
expdp user/passwd@orcl tables=table1=‘where id=1’ dumpfile=expdp.dmp directory=data_dir logfile=expdp.log;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值