ORA-02085: database link string connect to string
Posted on 2017-08-21 15:33 张鑫的园子 阅读(445) 评论(0) 编辑 收藏 举报ORA-02085: database link string connects to string
- Cause: a database link connected to a database with a different name. The connection is rejected.
- Action: create a database link with the same name as the database it connects to, or set global_names=false.
当数据库GLOBAL_NAMES参数设置为TRUE时,使用DB LINK连接其他库,DB LINK的名称必须与被连接库的GLOBAL_NAME一致,否则就会报这个错误。
测试:
ORCL 连接 DB11G数据库:
查看orcl库的global_names参数:
SQL> show parameter global_names NAME TYPE VALUE ------------------------------------ ----------- --------- global_names boolean FALSE SQL> select * from global_name;; GLOBAL_NAME ---------------------------------------------------------- ORCL
查看db11g库的参数设置:
SQL> show parameter global_names NAME TYPE VALUE ------------------------------------ ----------- ------- global_names boolean FALSE SQL> select * from global_name; GLOBAL_NAME -------------------------------------------------------- DB11G
创建db_link,并查询,查询无问题:
SQL> create public database link testlk1 connect to scott identified by tiger using 'db11g'; Database link created. SQL> SQL> select * from dual@testlk1; D - X
将db11g数据库的global_names参数修改为true后,查询依然不会报错,也可以继续创建新的dblink。但是将orcl库的global_names参数修改为true时,查询将报如下错误:
SQL> alter system set global_names=true; System altered. SQL> select * from dual@testlk1; select * from dual@testlk1 * ERROR at line 1: ORA-02085: database link TESTLK1 connects to DB11G
而创建一个与db11g同名的dblink时,查询正常:
SQL> create public database link db11g connect to scott identified by tiger using 'db11g'; Database link created. SQL> select * from dual@db11g; D - X
因此,global_names参数设置为TRUE时,将导致本库创建db_link时受限。也就是说,如果一个库(实例)的global_names参数设值为TRUE,该数据库使用dblink连接其他库是,dblink名称必须要与被连接的库的global_name相同。