7

I am logged in as the dba account and I want to create a view in User1's schema, but selecting data from User2's.

I used the following query:

CREATE OR REPLACE VIEW User1.NewView (Column1) AS
SELECT DISTINCT Column1 FROM User2.Table

and I get the following error:

SQL Error: ORA-00942: table or view does not exist
00942. 00000 -  "table or view does not exist"
*Cause:    
*Action:

To resolve this I had to grant select access to User1 on User2.Table. Is there a way to do this without having to grant access, since I am already logged in as the dba?

4

3 回答 3

11

是的,您必须(并且始终应该)明确授予对另一个模式中对象的访问权限。

GRANT SELECT ON user2.table TO user1

尽管您以“dba 帐户”(我假设是 SYS)身份登录,但 CREATE 语句专门针对 user1 模式。

于 2010-11-02T21:43:58.410 回答
8

你可以做 CREATE OR REPLACE FORCE VIEW ...

尽管没有权限,这将创建视图,但除非授予权限,否则该视图将不可用。如果稍后将授予权限(例如在某些自动构建脚本中),这是一个有用的解决方案。

于 2010-11-02T22:39:15.693 回答
0

可能是因为您无权访问表或视图

查询授予用户对象的权限;

于 2013-12-05T11:11:25.387 回答