尽管创建了同义词,表或视图却不存在

问题描述 投票:0回答:1

我正在尝试在 Schema1 中为 Schema2 中的表创建同义词。 但是,尽管同义词已成功创建,但我发现表或视图不存在。 非常感谢立即提出建议!!

create synonym ABC for Schema1.ABC;

select * from ABC

table or view does not exist
sql oracle synonym
1个回答
0
投票

在我的数据库中,以

scott
连接,我正在为用户
mike
拥有的表创建同义词:

SQL> connect mike/lion@orcl
Connected.

SQL> select * from trades;

       COL
----------
       100

返回

scott
,创建同义词:

SQL> connect scott/tiger@orcl
Connected.
   
SQL> create synonym abc for mike.trades;

Synonym created.

我现在可以选择吗?不,我得到了你得到的错误:

SQL> select * from abc;
select * from abc
              *
ERROR at line 1:
ORA-00942: table or view does not exist

为什么?因为

mike
不让我使用它的桌子!首先授予权限!

SQL> connect mike/lion@orcl
Connected.

SQL> grant select on trades to scott;

Grant succeeded.

SQL> connect scott/tiger@orcl
Connected.

SQL> drop synonym abc;

Synonym dropped.

SQL> create synonym abc for mike.trades;

Synonym created.

SQL> select * from abc;

       COL
----------
       100

现在可以了。

© www.soinside.com 2019 - 2024. All rights reserved.