network_link使用

通过使用network_link,可以对另一oracle数据库中的数据进行操作,具体可分两种,一是impdp,另一是expdp。
impdp使用network_link可以将另一oracle数据库中的数据导出并导入到本oracle数据库中,其中不会生成dmp文件,只有日志文件;
expdp使用networ_link可以将另一oracle数据库中的数据以dmp文件的行式导出到本数据库目录中。

环境:因为我只有一个数据库,所以这里通过使用两个用户来模拟这种情况。
具体实现是test用户相当于另一数据库中的用户,不给test用户赋使用目录marcus_dump_dir的权限,不然我们没法区分使用的是本数据库的目录还是另一数据库的目录。

具体步骤如下:

--1.创建表空间
create tablespace dasong
datafile '/opt/oracle/oradata/dasong/dasong.dbf' size 100m reuse
autoextend on;

--2.创建用户dasong并赋权限
create user dasong identified by dasong
default tablespace dasong
temporary tablespace temp;

grant create session to dasong;
grant resource to dasong;
grant debug connect session to dasong;
grant debug any procedure to dasong;
grant select any dictionary to dasong;
grant create database link to dasong;

--3.创建用户test并赋权限
create user test identified by test
default tablespace dasong
temporary tablespace temp;

grant create session to test;
grant resource to test;
grant debug connect session to test;
grant debug any procedure to test;
grant select any dictionary to test;
grant create database link to test;

--4.创建目录,并给用户dasong赋使用权限,注意不要给test赋使用权限,不然我们没法区分使用的是本数据库的目录还是另一数据库的目录
create directory marcus_dump_dir as '/home/oracle/marcus_dump_dir';
grant all on directory marcus_dump_dir to dasong;

--创建数据库链
--drop public database link dblink_test;
create public database link dblink_test
connect to test identified by test
using
'(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dasong)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = dasong)
    )
  )
';

--将用户test中的所有对像导入到用户dasong中,在导入的过程中不会生成dmp文件,只有日志文件
impdp userid=dasong/dasong network_link=dblink_test directory=marcus_dump_dir remap_schema=test:dasong

--使用用户dasong导出用户test的数据
expdp userid=dasong/dasong network_link=dblink_test directory=marcus_dump_dir dumpfile=test.dmp

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7417681/viewspace-710094/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7417681/viewspace-710094/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值