一个开发商反映,使用DB_LINK的时候,数据库报ORA-02085的错误,DB_LINK 以前是可以用的,现在突然不可以用了.
检查了数据库的环境,大致情况如下:
$more $ORACLE_HOME/network/admin/tnsnames.ora
XSDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 12.56.123.97 )(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 12.56.123.98 )(PORT = 1521))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
创建db_link的语句:
SQL>Create database link "SJLL" connect to USER1 identified by "PWD_USER1" using 'XSDB';
通过DB_LINK访问远程数据库的对象是报了ORA-02058的错误
SQL>select * from tab1@sjll;
ORA-02058 "database link %s connects to %s"
问题解决的步骤
1.通过oracle的工具oerr,查找这个错误的描述
[oracle@localhost admin]$ oerr ora 2085
02085, 00000, "database link %s connects to %s"
// *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.
//
2.更改global_names参数
[oracle@localhost admin]$ sqlplus / as sysdba
SQL> show parameter global_names
NAME TYPE----------------------VALUE
------------------------------
global_names boolean TRUE
SQL> alter system set global_names=false scope=both;
System altered.
SQL> exit
3.远程数据库访问正常
SQL>select * from tab1@sjll;
......
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/32980/viewspace-1056768/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/32980/viewspace-1056768/