問題描述
我以 dba 帳戶登錄,我想在 User1 的架構中創建一個視圖,但從 User2 的架構中選擇數據.
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.
我使用了以下查詢:
CREATE OR REPLACE VIEW User1.NewView (Column1) AS
SELECT DISTINCT Column1 FROM User2.Table
我收到以下錯誤:
SQL Error: ORA-00942: table or view does not exist
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
為了解決這個問題,我必須在 User2.Table 上授予對 User1 的選擇訪問權限.因為我已經以 dba 身份登錄,所以有沒有一種無需授予訪問權限的方法?
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?
推薦答案
是的,您必須(并且始終應該)明確授予對另一個架構中的對象的訪問權限.
Yes, you have (and always should) to explicitly grant access to objects in another schema.
GRANT SELECT ON user2.table TO user1
盡管您以dba 帳戶"(我假設是 SYS)身份登錄,但 CREATE 語句專門針對 user1 架構.
Though you're logged in as "the dba account" (SYS, I'm assuming), the CREATE statement is for the user1 schema specifically.
這篇關于Oracle 創建視圖問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!