如何调试 ORA-01775:同义词循环链?
我熟悉 ORA-01775: 循环同义词链背后的问题,但是有什么技巧可以调试它,还是我只需要“创建或替换”我的方式来摆脱它?
有没有办法查询架构或其他方式来找出公共同义词的当前定义是什么?
更棒的是图形工具,但在这一点上,任何东西都会有帮助。
I'm familiar with the issue behind ORA-01775: looping chain of synonyms, but is there any trick to debugging it, or do I just have to "create or replace" my way out of it?
Is there a way to query the schema or whatever to find out what the current definition of a public synonym is?
Even more awesome would be a graphical tool, but at this point, anything would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(18)
事实证明,问题实际上并不是同义词的循环链,而是同义词指向了一个不存在的视图。
在这种情况下,Oracle 显然会错误地作为循环链。
As it turns out, the problem wasn't actually a looping chain of synonyms, but the fact that the synonym was pointing to a view that did not exist.
Oracle apparently errors out as a looping chain in this condition.
如果您使用 TOAD,请转至 View>Toad Options>Oracle>General,然后从 EXPLAIN PLAN 部分中删除 TOAD_PLAN_TABLE 并放置 PLAN_TABLE
If you are using TOAD, go to View>Toad Options>Oracle>General and remove TOAD_PLAN_TABLE from EXPLAIN PLAN section and put PLAN_TABLE
数据字典表
DBA_SYNONYMS
包含有关数据库中所有同义词的信息。 因此,您可以运行查询来查看公共同义词当前指向的内容。
The data dictionary table
DBA_SYNONYMS
has information about all the synonyms in a database. So you can run the queryto see what the public synonym currently points at.
此错误代码的不太直观的解决方案似乎是同义词所指向的对象存在问题。
这是我用于查找指向错误对象的同义词的 SQL。
The less intuitive solution to this error code seems to be problems with the objects that the synonym is pointing to.
Here is my SQL for finding synonyms that point to erroneous objects.
尝试此选择来查找有问题的同义词,它列出了指向不存在的对象的所有同义词(表、视图、序列、包、过程、函数)
Try this select to find the problematic synonyms, it lists all synonyms that are pointing to an object that does not exist (tables,views,sequences,packages, procedures, functions)
今天我得到了这个错误,经过调试后我发现实际的表丢失了,我是使用同义词来引用的。 所以我建议 - 首先检查表是否存在! :-))
Today I got this error, and after debugging I figured out that the actual tables were misssing, which I was referring using synonyms. So I suggest - first check that whether the tables exists!! :-))
步骤 1) 查看该名称存在哪些对象:
可能存在同义词但不存在表?
步骤 2) 如果这不是问题,请调查同义词:
可能缺少该同义词的基础表或视图?
Step 1) See what Objects exist with the name:
It could be that a Synonym exists but no Table?
Step 2) If that's not the problem, investigate the Synonym:
It could be that an underlying Table or View to that Synonym is missing?
开发人员意外编写了生成并运行以下 SQL 语句的代码
CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "DUAL";
,这导致select * from dba_synonyms where table_name = 'DUAL';
返回PUBLIC DUAL SOME_USER DUAL
而不是PUBLIC DUAL SYS DUAL
。我们能够修复它(感谢如何重新创建公共同义词“DUAL”?) 通过运行
A developer accidentally wrote code that generated and ran the following SQL statement
CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "DUAL";
which causedselect * from dba_synonyms where table_name = 'DUAL';
to returnPUBLIC DUAL SOME_USER DUAL
rather thanPUBLIC DUAL SYS DUAL
.We were able to fix it (thanks to How to recreate public synonym "DUAL"?) by running
虽然 Jarrod 的答案是一个好主意,并且涵盖了更广泛的相关问题,但我发现在 Oracle 论坛中找到的这个查询可以更直接地解决(最初陈述的)问题:
https://community.oracle.com/message/4176300#4176300
您不必费力地浏览其他类型的无效对象。 只是那些实际上处于无限循环中的内容。
While Jarrod's answer is a good idea, and catches a broader range of related problems, I found this query found in Oracle forums to more directly address the (originally stated) issue:
https://community.oracle.com/message/4176300#4176300
You will not have to wade through other kinds of invalid objects. Just those that are actually in endless loops.
我遇到了类似的问题,结果是由于表和模式名称中缺少双引号引起的。
I had a similar problem, which turned out to be caused by missing double quotes off the table and schema name.
我们遇到了相同的 ORA-01775 错误,但在我们的例子中,模式用户在几个公共同义词上缺少一些“授予选择”。
We had the same ORA-01775 error but in our case, the schema user was missing some 'grant select' on a couple of the public synonyms.
我们今天遇到了这个错误。
这就是我们调试和修复它的方法。
由于此错误
ORA-01775
,程序包进入无效状态。根据错误行号,我们检查了
package
主体代码,找到了试图将数据插入表
的代码。我们运行以下查询来检查上述
表
和同义词
是否存在。据此我们得出结论,需要重新创建该表。 由于
同义词
指向一个不存在的表
。DBA 团队重新创建了该表,这解决了该问题。
We encountered this error today.
This is how we debugged and fixed it.
Package went to invalid state due to this error
ORA-01775
.With the error line number , We went thru the
package
body code and found the code which was trying to insert data into atable
.We ran below queries to check if the above
table
andsynonym
exists.With this we concluded that the table needs to be re- created. As the
synonym
was pointing to atable
that did not exist.DBA team re-created the table and this fixed the issue.
ORA-01775: 同义词循环链
当我尝试编译一个包时,我遇到了上述错误,该包使用的对象已创建同义词,但底层对象不可用。
ORA-01775: looping chain of synonyms
I faced the above error while I was trying to compile a Package which was using an object for which synonym was created however underlying object was not available.
我使用以下 sql 来查找 all_synonyms 中没有与 object_name 对应的对象的条目(在 user_objects 中):
I'm using the following sql to find entries in all_synonyms where there is no corresponding object for the object_name (in user_objects):
http://ora-01775.ora-code.com/ 建议:
ORA-01775: 同义词循环链
原因:通过一系列 CREATE 同义词语句,定义了一个引用自身的同义词。 例如,以下定义是循环的:
为 s2 创建同义词 s1 为 s3 创建同义词 s2 为 s1 创建同义词 s3
操作:更改一个同义词定义,以便将其应用于基表或视图,然后重试该操作。
http://ora-01775.ora-code.com/ suggests:
ORA-01775: looping chain of synonyms
Cause: Through a series of CREATE synonym statements, a synonym was defined that referred to itself. For example, the following definitions are circular:
CREATE SYNONYM s1 for s2 CREATE SYNONYM s2 for s3 CREATE SYNONYM s3 for s1
Action: Change one synonym definition so that it applies to a base table or view and retry the operation.
如果您正在编译一个 PROCEDURE,则这可能引用了一个在同一 PROCEDURE 中创建时不存在的表或视图。 在这种情况下,解决方案是将查询声明为字符串,例如
v_query: = 'insert into table select * from table2
,然后立即执行v_query
;这是因为编译器尚未识别该对象,因此找不到引用。 问候。
If you are compiling a PROCEDURE, possibly this is referring to a table or view that does not exist as it is created in the same PROCEDURE. In this case the solution is to make the query declared as String eg
v_query: = 'insert into table select * from table2
and then execute immediate onv_query
;This is because the compiler does not yet recognize the object and therefore does not find the reference. Greetings.
我在错误的架构中定义了一个函数,并且没有公共同义词。 即我的过程位于模式“Dogs”中,函数位于模式“Cats”中。 该函数没有公共同义词来允许狗访问猫的函数。
I had a function defined in the wrong schema and without a public synonym. I.e. my proc was in schema "Dogs" and the function was in schema "Cats". The function didn't have a public synonym on it to allow Dogs to access the cats' function.
对我来说,表名和同义词都存在,但所有者名称不同。 我在所有者名称下重新创建了与同义词中的所有者名称相匹配的表。
我使用了@Mahi_0707 发布的查询
For me, the table name and the synonym both existed but under different owner names. I re-created the tables under the owner name that matched the owner name in synonyms.
I used the queries posted by @Mahi_0707