For v$ views you need to grant privilege to each v_$ directly

brightking716發表於2010-07-15
最近在看Thomas Kyte的<Expert Oracle.Database.Architecture.9i.and.10g>,在定製環境的時候,執行以下指令碼,出現問題: scott@SHENZHEN> grant select any table to scott;
scott@SHENZHEN> create or replace view stats
as select 'STAT...' || a.name name, b.value
from v$statname a, v$mystat b
where a.statistic# = b.statistic#
union all
select 'LATCH.' || name, gets
from v$latchlatch
union all
9 select 'STAT...Elapsed Time', hsecs from v$timer;
from v$statname a, v$mystat b
*
ERROR at line 3:
ORA-01031: insufficient privileges
[@more@]
欲將這幾個動態效能檢視的select許可權單獨賦給Scott:
sys@SHENZHEN> grant select on v$mystat to scott;
grant select on v$mystat to scott
*
ERROR at line 1:
ORA-02030: can only select from fixed tables/views
查詢後發現,原來v$物件,並不是檢視,而是指向v_$檢視的同義詞,而檢視是基於真正的v$檢視建立的。
還有X$表,這一部分表是Oracle資料庫的執行基礎,在資料庫啟動時由Oracle應用程式動態建立。
這部分表對資料庫來說至關重要,所以Oracle不允許SYSDBA之外的使用者直接訪問,顯示授權不被允許。
將select許可權賦給4個v_$檢視
sys@SHENZHEN> grant select on v_$mystat to scott;
Grant succeeded.
sys@SHENZHEN> grant select on v_$statname to scott;
Grant succeeded.
sys@SHENZHEN> grant select on v_$latch to scott;
Grant succeeded.
sys@SHENZHEN> grant select on v_$timer to scott;
Grant succeeded.
scott@SHENZHEN> create or replace view stats
2 as select 'STAT...' || a.name name, b.value
3 from v$statname a, v$mystat b
4 where a.statistic# = b.statistic#
5 union all
6 select 'LATCH.' || name, gets
7 from v$latch
8 union all
9 select 'STAT...Elapsed Time', hsecs from v$timer;
View created.
問題解決!
Reference:
http://space.itpub.net/9252210/viewspace-591741
http://zhangsolomon.itpub.net/post/39913/488842
http://blog.csdn.net/yang073402/archive/2010/04/13/5482987.aspx

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12472709/viewspace-1035308/,如需轉載,請註明出處,否則將追究法律責任。

相關文章