DB_LINK创建

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:351

Machine 1:
  IP:10.80.18.241

  Machine 2:
  IP:10.80.18.245

  1.在Machine 2的数据库中增加用户
  以oracle用户登录Machine 2

  $sqlplus / as sysdba
  SQL>create user test identified by test;
  User created.
  SQL>grant connect,resource to test;
  Grant succeeded.
  2.修改Machine 1的tnsnames.ora文件
  增加如下内容:
  scofy =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.80.18.245)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = scofy)
)
)
  3.创建db link
  以oracle用户登录Machine 1

  $sqlplus / as sysdba
  SQL>create public database link prepaid_test connect to test identified by test using 'scofy';
  Database link created.
  SQL>show parameter global_names
  NAME TYPE VALUE
  ------------------------------------ ----------- ------------------------------
  global_names boolean TRUE
  SQL>select * from dual@prepaid_test;
  select * from dual@prepaid_test
  *
  ERROR at line 1:
  ORA-02085: database link PREPAID_TEST connects to PREPAID
  SQL>alter system set global_names=false;
  System altered.
  SQL>select * from dual@prepaid_test;

  D
  -
  X
  可以看到,当global_names=false时,db link可以连接远程数据库。

  当global_names=true时,如果创建的db link名字与远程数据库的实例名一致,还是可以访问的。

本文标签:
本文标题:DB_LINK创建
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】