oracle ORA-00942: 表或视图不存在错误,即使我授予用户选择权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24363893/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:24:08  来源:igfitidea点击:

ORA-00942: table or view does not exist error is given even though I granted Select privilege to the user

oracle

提问by brainmassage

For my Oracle database I created a user. I want that user to have access to only 3 tables. So I wrote those queries:

我为我的 Oracle 数据库创建了一个用户。我希望该用户只能访问 3 个表。所以我写了这些查询:

grant select on table1 to newuser;
grant select on table2 to newuser;
grant select on table3 to newuser;

And I got this from the console, which ensures that I gave the grant.

我从控制台得到了这个,这确保了我给予了补助。

GRANT succeeded

However when I connect to database with this user and write the following query, I get ORA-00942 error.

但是,当我使用该用户连接到数据库并编写以下查询时,出现 ORA-00942 错误。

Select * from table1;

I think I need to write additional queries for privileges and roles(I already added CONNECT role). What might it be?

我想我需要为权限和角色编写额外的查询(我已经添加了 CONNECT 角色)。可能是什么?

回答by Lokesh

Run the query by specifying table owner.

通过指定表所有者运行查询。

Select * from tableowner.table1;

If this doesn't work then either you have not granted access on correct table or you are logged in with wrong user.

如果这不起作用,那么要么您没有授予对正确表的访问权限,要么您使用错误的用户登录。

remember same table name can exist in multiple schemas.

记住相同的表名可以存在于多个模式中。

回答by Nishanthi Grashia

Assume that,

假使,假设,

  • NEWUSER--> THE user to which a grant has been provided.

  • EXISTINGUSER--> The owner of the table for which a grant is provided.

  • NEWUSER--> 已向其提供授权的用户。

  • EXISTINGUSER--> 为其提供授权的表的所有者。

Login as EXISTINGUSER, and enter following query:

EXISTINGUSER身份登录,然后输入以下查询:

GRANT SELECT ON TABLE1 TO NEWUSER ;

Login as NEWUSER, and select using:

NEWUSER身份登录,然后选择使用:

SELECT * FROM EXISTINGUSER.TABLE1;

In case you want to avoid using "EXISTINGUSER"."TABLE1", then you can create a synonym, which is equivalent to a ALIAS NAME:

如果您想避免使用 "EXISTINGUSER"."TABLE1",那么您可以创建一个同义词,它相当于一个ALIAS NAME

Login as NEWUSER, enter following query:

NEWUSER身份登录,输入以下查询:

CREATE SYNONYM SYN_TABLE1 FOR EXISTINGUSER.TABLE1;

For selecting data from synonym, login as NEWUSERand select using:

要从同义词中选择数据,请以NEWUSER身份登录并选择使用:

SELECT * FROM SYN_TABLE1;

Synonym Reference: http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm

同义词参考:http: //docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm