oracle 如何正确制作公共同义词
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8995098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to correctly make a public synonym
提问by Joe
This is a pretty silly one, but I need help.
这是一个非常愚蠢的问题,但我需要帮助。
I have a table owned by mydbowner. It is named mydbowner.mytable. I tried to make a public synonym by issuing the command:
我有一张由 mydbowner 拥有的桌子。它被命名为 mydbowner.mytable。我试图通过发出以下命令来创建一个公共同义词:
CREATE OR REPLACE PUBLIC SYNONYM mytable FOR mydbowner.mytable;
为 mydbowner.mytable 创建或替换公共同义词 mytable;
When I do this, and I query the table I get:
当我这样做时,我查询了我得到的表:
ORA-01775: looping chain of synonyms
ORA-01775:同义词循环链
How do I make this synonym without having the problem.
我如何在没有问题的情况下制作这个同义词。
回答by Mark J. Bobak
I think Justin is on the right track. What I think it actually means is that mydbowner.mytable doesn't exist.
我认为贾斯汀走在正确的轨道上。我认为这实际上意味着 mydbowner.mytable 不存在。
Here's an example:
下面是一个例子:
SQL> conn mbobak
Enter password:
Connected.
SQL> drop table mytable;
drop table mytable
*
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> create public synonym mytable for mbobak.mytable;
Synonym created.
SQL> select * from mytable;
select * from mytable
*
ERROR at line 1:
ORA-01775: looping chain of synonyms
I think what's happening is that Oracle tries to resolve mytable, there is no mytable in mbobak schema, so it looks for it in PUBLIC, it finds it, and sees that it points to mbobak.mytable. But, mbobak.mytable doesn't exist, so, it looks for mytable in PUBLIC, and there's the loop.
我认为发生的事情是 Oracle 尝试解析 mytable,mbobak 模式中没有 mytable,所以它在 PUBLIC 中查找它,找到它,并看到它指向 mbobak.mytable。但是,mbobak.mytable 不存在,因此,它在 PUBLIC 中查找 mytable,并且存在循环。
And in fact, if you create mytable, the error goes away:
事实上,如果你创建 mytable,错误就会消失:
SQL> create table mytable as select * from dual;
Table created.
SQL> select * from mytable;
D
-
X
1 row selected.
SQL> drop table mytable;
Table dropped.
SQL> select * from mytable;
select * from mytable
*
ERROR at line 1:
ORA-01775: looping chain of synonyms
Yes, I realize that doesn't really entirely make sense, as, once the public synonym resolved to mbobak.mytable, and that's not found, it seems to me, it should return an error ORA-942 "table or view does not exist", which makes far more sense to me.
是的,我意识到这并不完全有意义,因为一旦公共同义词解析为 mbobak.mytable,并且没有找到,在我看来,它应该返回错误 ORA-942“表或视图不存在”,这对我来说更有意义。
But, this does seem to be how it works.
但是,这似乎是它的工作原理。
QED
QED
Hope that helps.
希望有帮助。
回答by Justin Cave
The error you're getting implies that mydbowner.mytable
is not, in fact a table. What does
你得到的错误暗示这mydbowner.mytable
实际上不是一张桌子。有什么作用
SELECT object_type
FROM all_objects
WHERE owner = 'MYDBOWNER'
AND object_name = 'MYTABLE'
return?
返回?