ITPub博客

首页 > 数据库 > Oracle > network_link使用

network_link使用

原创 Oracle 作者:dasong2410 时间:2011-11-02 11:21:40 0 删除 编辑
通过使用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博客 ” ,链接:https://blog.itpub.net/7417681/viewspace-710094/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: oracle外部表示例
请登录后发表评论 登录
全部评论

注册时间:2011-05-12

  • 博文量
    66
  • 访问量
    349769