ORA-02030: can only select from fixed tables/views
今天在測試的過程中遇到了一個小問題,這讓我產生了疑惑:為什麼單獨執行的時候就可以,而在建立view的時候就會提示沒有許可權?
SEIANG@seiang11g>select value from v$mystat, v$statname
2 where v$mystat.statistic# = v$statname.statistic#
3 and v$statname.name = 'redo size';
VALUE
----------
29152
SEIANG@seiang11g>create or replace view redo_size1
2 as
3 select value from v$mystat, v$statname
4 where v$mystat.statistic# = v$statname.statistic#
5 and v$statname.name = 'redo size';
select value from v$mystat, v$statname
*
ERROR at line 3:
ORA-01031: insufficient privileges
起初,還以為是沒有create view的許可權,於是就查詢了seiang使用者的去許可權檢視:
SEIANG@seiang11g>select * from role_sys_privs where PRIVILEGE = 'CREATE VIEW';
ROLE PRIVILEGE ADM
---------- ---------------------------------------- ---
DBA CREATE VIEW YES
問題解決:
第一次:
SYS@seiang11g>GRANT SELECT ANY DICTIONARY to seiang;
Grant succeeded.
SEIANG@seiang11g>create or replace view redo_size
2 as
3 select value from v$mystat, v$statname
4 where v$mystat.statistic# = v$statname.statistic#
5 and v$statname.name = 'redo size';
View created.
回收許可權,繼續試驗
SYS@seiang11g>revoke SELECT ANY DICTIONARY from seiang;
Revoke succeeded.
SEIANG@seiang11g>create or replace view redo_size1
2 as
3 select value from v$mystat, v$statname
4 where v$mystat.statistic# = v$statname.statistic#
5 and v$statname.name = 'redo size';
select value from v$mystat, v$statname
*
ERROR at line 3:
ORA-01031: insufficient privileges
第二次:
SYS@seiang11g>grant select on v$statname to seiang;
grant select on v$statname to seiang
*
ERROR at line 1:
ORA-02030: can only select from fixed tables/views
SYS@seiang11g> select * from dba_synonyms t where t.synonym_name = 'V$STATNAME';
OWNER SYNONYM_NAME TABLE_OWNER TABLE_NAME DB_LINK
---------- --------------- -------------- ------------------------------ --------------------
PUBLIC V$STATNAME SYS V_$STATNAME
分析:對以v$開頭的檢視,不能直接grant,v$開頭的檢視是v_$的同義詞
第三次:
SYS@seiang11g>grant select on v_$statname to seiang;
Grant succeeded.
SEIANG@seiang11g>create or replace view redo_size1
2 as
3 select value from v$mystat, v$statname
4 where v$mystat.statistic# = v$statname.statistic#
5 and v$statname.name = 'redo size';
select value from v$mystat, v$statname
*
ERROR at line 3:
ORA-01031: insufficient privileges
SYS@seiang11g>grant select on v_$mystat to seiang;
Grant succeeded.
SEIANG@seiang11g>create or replace view redo_size3
2 as
3 select value from v$mystat, v$statname
4 where v$mystat.statistic# = v$statname.statistic#
5 and v$statname.name = 'redo size';
View created.
下面是Oracle 11g官方文件的解釋說明:
*******************************************************************************
To create a view in your own schema, you must have the CREATE VIEW system privilege. To create a view in another user's schema, you must have the CREATEANY VIEW system privilege.
要在自己的schema中建立檢視,必須具有CREATE VIEW系統去許可權。 要在其他使用者的schema中建立檢視,必須具有CREATE ANY VIEW系統許可權。
To create a subview, you must have the UNDER ANY VIEW system privilege or the UNDER object privilege on the superview.
要建立一個子檢視,必須具有UNDER ANY VIEW系統許可權或者該超級檢視的UNDER物件許可權。
The owner of the schema containing the view must have the privileges necessary to either select, insert, update, or delete rows from all the tables or views on which the view is based. The owner must be granted these privileges directly, rather than through a role.
包含檢視schema的所有者必須具有從檢視(基於的所有表或檢視)中選擇,插入,更新或刪除行所必需的許可權。 所有者必須直接授予這些許可權,而不是通過角色授予。
作者:SEian.G(苦練七十二變,笑對八十一難)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31015730/viewspace-2145385/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle:ORA-01219:database not open:queries allowed on fixed tables/views onlyOracleDatabaseView
- Views and Base Tables (243)View
- Validating Tables, Indexes, Clusters, and Materialized ViewsIndexZedView
- Oracle Materialized Views Containing Joins OnlyOracleZedViewAI
- ORA-02030 WHEN GRANTING SELECT ON V$ VIEWView
- for public synonym, only sys user can compile it?Compile
- 子執行緒呼叫invalidate()產生“Only the original thread that created a view hierarchy can touch its views.”原因分析執行緒threadView
- SELECT INTO FROM mysql Undeclared variableMySql
- External Tables: Querying Data From Flat Files in OracleOracle
- mac提交svn提示CHECKOUT can only be performed on a version resourceMacORM
- TypeError: only integer scalar arrays can be converted to a scalar indexErrorIndex
- Android @Field parameters can only be used with form encodingAndroidORMEncoding
- 錯誤處理--pure specifier can only be specified for functionsFunction
- Mysql報錯Fatal error:Can't open and lock privilege tablesMySqlError
- Read-Only Tables in Oracle Database 11g Release 1OracleDatabase
- Select from subquery 子查詢
- "Only fullscreen opaque activities can request orientation "問題再分析Opaque
- Oracle 12C新特性-資料泵新引數(VIEWS_AS_TABLES)OracleView
- select into from 和 insert into select 的用法和區別
- "ScrollView can host only one direct child"問題解決View
- Only a type can be imported. classname resolves to a package的解決ImportPackage
- Swift代理報錯Optional can only be applied to members of an @objc protocolSwiftAPPOBJProtocol
- You can‘t specify target table ‘Person‘ for update in FROM clause
- [20121101]物化檢視與表(Materialized Views and Tables).txtZedView
- SQL-Hive中的Select From解析SQLHive
- 優化select count(*) from t1優化
- Android8.0適配-Only fullscreen opaque activities can request orientationAndroidOpaque
- mybatis中insert into ...select ...from dual union all select ... from dual 提示sql命令未結束的問題MyBatisSQL
- mysql中You can’t specify target table for update in FROM clMySql
- Can one execute an operating system command from PL/SQL?SQL
- 解決Android 8 0的Only fullscreen opaque activities can request orientatioAndroidOpaque
- How can I prevent users from connecting to a USB storage device?dev
- ORA-22992 cannot use LOB locators selected from remote tablesREM
- DIA-48449: Tail alert can only apply to single ADR homeAIAPP
- select hang住等待SQL*Net message from ClientSQLclient
- eclise 部署web工程報 There are no resources that can be added or removed from the server.WebREMServer
- [ OCRSRV][21]th_select_handler: Failed to retrieve procctx from......AI
- Fixed with absolute