ORA-02085错误解决过程!

       今天看EYGLE的文章:http://www.eygle.com/archives/2005/06/oraclessoeaeaeo.html(Oracle高级复制的创建配置步骤-Step by Step),里面讲到了:本例的先决条件:你需要设置好相应的参数,job_queue_processes需要大于0,global_name=true,并且建立相应的db link.

      于是我这个菜鸟便检查主数据库job_queue_processes和global_names参数,并通过alter system set global_names=true;修改global_names参数,没有任何问题!

   然后在主数据库创建dblink:

 create database link test_link
  connect to myuser identified by pass
  using 'mydb2';

创建过程也没有问题!但是使用dblink进行查询就出错了:

SQL> select count(*) from town@test_link;

select count(*) from town@test_link

ORA-02085: database link TEST_LINK connects to STIOMDB

SQL>

经过在网上搜看别人的帖子并测试发现:

当global_name参数设置为true,则dblink必须命名为和在目标数据库如下查询出的结果一致:

 select * from global_name,例如:

在目标数据库执行查询:

 

SQL>  select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------
mydb

SQL>

 

则修改dblink:

 create database link mydb  connect to myuser identified by pass  using 'mydb2';

然后执行查询:

SQL> select count(*) from town@mydb;

  COUNT(*)
----------
     13507

SQL>

 

具体可参考如下描述:(摘自:http://www.itpub.net/364993.html)

 

When the source database initialization parameter GLOBAL_NAMES is set to true, the

database link name must match the target database global name as it exists in the GLOBAL_NAME

view in the data dictionary.

The GLOBAL_NAME can be determined by logging in to the database with system privileges and issuing the following command:

SQL>Select * from global_name;

Additionally, if you do not specify the domain portion of the dblink name in the create statement, Oracle automatically qualifies the link name with the domain of the SOURCE database global name view.

Check the contents of ALL_DB_LINKS for the fully qualified link name.

For example, if you defined a database link in PROD.ORACLE.COM to connect to target instance TEST.WORLD.COM in the following manner:

SQL>Create public database link TEST connect to userid identified by password using ?test?;

SQL>select * from tablename@TEST;

This select would yield the following error:

ORA-2085 "database link TEST.ORACLE.COM connects to TEST.WORLD.COM"

The correct syntax for defining the link would be:

SQL>Create public database link TEST.WORLD.COM connect to userid identified by password using “test”;

SQL>select * from tablename@TEST.WORLD.COM;

Would yield desired result.

It is possible to alter the GLOBAL_NAME table so that the domain portion of both SOURCE and TARGET global names are identical. This would eliminate the need to include the domain in the create database link statement.

In the above example, we could alter the GLOBAL_NAME of TEST.WORLD.COM in the following manner:

Login to TEST with system privileges and issue:

SQL>alter database rename global_name to TEST.ORACLE.COM;

Now, the create database link statement could also be changed.

Login to PROD.

SQL>create public database link TEST connect to userid identified by password using ?test?;

A database link would be defined in ALL_DB_LINKS as TEST.ORACLE.COM.

SQL>select * from tablename@TEST;

This would yield the desired result.

 

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
ORA-31011是Oracle数据库中的一个错误,表示在XML类型的数据执行操作时发生了错误ORA-19202是XML DB错误,表示在处理XML数据时发生了错误。以下是解决这两个错误的一些常见方法: 1. 确保你的XML数据是有效的:检查XML数据是否符合XML规范,确保没有语法错误或格式问题。你可以使用XML验证工具来验证XML数据的有效性。 2. 检查XML类型的列或变量的定义:确保你在数据库中正确定义了XML类型的列或变量。检查表结构或存储过程中的定义,确保与实际使用的XML数据类型匹配。 3. 检查相关权限:确保你有足够的权限来执行操作,例如访问和修改XML类型的数据。如果你没有足够的权限,联系数据库管理员获取相应的权限。 4. 检查数据库版本和补丁:某些版本的Oracle数据库可能存在已知的问题或错误,可以通过升级数据库版本或应用相关的补丁来解决。确保你使用的是最新的数据库版本,并且已经应用了所有必要的补丁。 5. 检查相关配置和参数设置:有时候,特定的配置或参数设置可能会导致ORA-31011和ORA-19202错误。检查数据库配置文件(如init.ora或spfile)中的相关参数设置,确保它们正确配置。 如果以上方法无法解决问题,建议你查看具体的错误信息和错误堆栈跟踪,以便更准确地确定问题所在。你可以在Oracle文档中搜索特定的错误代码,了解更多关于该错误的信息和解决方案。另外,如果问题持续存在,建议联系Oracle支持团队获取进一步的帮助和支持。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值