如何正确制作公开同义词 [英] How to correctly make a public synonym

查看:67
本文介绍了如何正确制作公开同义词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个非常愚蠢的,但是我需要帮助.

This is a pretty silly one, but I need help.

我有一个由mydbowner拥有的表.它名为mydbowner.mytable.我试图通过发出以下命令来成为公共同义词:

I have a table owned by mydbowner. It is named mydbowner.mytable. I tried to make a public synonym by issuing the command:

为mydbowner.mytable创建或替换公共SYNONYM mytable;

CREATE OR REPLACE PUBLIC SYNONYM mytable FOR mydbowner.mytable;

这样做时,我查询得到的表:

When I do this, and I query the table I get:

ORA-01775:循环同义词链

ORA-01775: looping chain of synonyms

如何在没有问题的情况下使用这个同义词?

How do I make this synonym without having the problem.

推荐答案

我认为贾斯汀走在正确的轨道上.我认为这实际上意味着mydbowner.mytable不存在.

I think Justin is on the right track. What I think it actually means is that mydbowner.mytable doesn't exist.

这是一个例子:

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

我认为正在发生的事情是Oracle尝试解析mytable,mbobak模式中没有mytable,因此它在PUBLIC中查找它,找到它,然后看到它指向mbobak.mytable.但是,mbobak.mytable不存在,因此,它在PUBLIC中查找mytable,并且存在循环.

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.

实际上,如果创建mytable,错误就会消失:

And in fact, if you create mytable, the error goes away:

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

是的,我意识到这并不是完全有意义,因为,一旦公共同义词解析为mbobak.mytable,并且在我看来,找不到它,它应该返回错误ORA-942表或视图"不存在",这对我来说意义更大.

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.

但是,这似乎是它的工作原理.

But, this does seem to be how it works.

QED

希望有帮助.

这篇关于如何正确制作公开同义词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆