檢視查詢報錯
今天發現一個奇怪的現象,在查詢一個檢視的時候,明明有許可權,但就是提示表或檢視不存在
--查詢檢視
SQL> select * from dba_tab_modifications;
select * from dba_tab_modifications
ORA-00942: 表或檢視不存在
--覺得可能是授權問題,於是進行授權
SQL> conn sys/space6212 as sysdba
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as SYS
SQL> grant select on dba_tab_modifications to suk;
Grant succeeded
SQL> grant select any dictionary to suk;
Grant succeeded
--授權後查詢仍然報錯
SQL> conn suk/suk
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as suk
SQL> select * from dba_tab_modifications;
select * from dba_tab_modifications
ORA-00942: 表或檢視不存在
--查詢加上schema後就能查詢了,注意,sys.dba_tab_modifications也是檢視
SQL> select * from sys.dba_tab_modifications;
TABLE_OWNER TABLE_NAME PARTITION_NAME SUBPARTITION_NAME INSERTS UPDATES DELETES TIMESTAMP TRUNCATED
------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------- ---------- ---------- ----------- ---------
SSK ITEM 0 889328 0 2006-7-19 1 NO
SSK PROCEDURE_ERR_RECORD 8 0 0 2006-7-19 1 NO
SUK CATEGORY 0 0 1 2006-8-8 13 NO
SUK ITEM 0 0 215 2006-8-8 13 NO
SUK PLAN_TABLE 84 0 84 2006-9-18 1 NO
SUK T 0 2 0 2006-9-19 1 YES
6 rows selected
--我們知道,一般情況下,我們在訪問DBA_、ALL_、USER_這些資料字典時,如果不加schema,則訪問的都是公用同義詞,難道DBA_TAB_MODIFICATIONS這個檢視沒有建立公用的同義詞?
SQL> select view_name from dba_views where view_name like 'DBA%' or view_name like 'USER%' or view_name like 'ALL%' minus select SYNONYM_NAME from dba_synonyms ;
VIEW_NAME
------------------------------
ALL_PROBE_OBJECTS
DBA_ANALYZE_OBJECTS
DBA_ATTRIBUTE_TRANSFORMATIONS
DBA_CACHEABLE_NONTABLE_OBJECTS
DBA_CACHEABLE_TABLES_BASE
DBA_FREE_SPACE_COALESCED_TMP1
DBA_FREE_SPACE_COALESCED_TMP2
DBA_FREE_SPACE_COALESCED_TMP3
DBA_IAS_CONSTRAINT_EXP
DBA_IAS_GEN_STMTS_EXP
DBA_IAS_OBJECTS_BASE
DBA_IAS_OBJECTS_EXP
DBA_IAS_POSTGEN_STMTS
DBA_IAS_PREGEN_STMTS
DBA_TAB_MODIFICATIONS
DBA_TRANSFORMATIONS
16 rows selected
--或者查詢publicsyn也可以知道
SQL> select * from publicsyn where sname='DBA_TAB_MODIFICATIONS';
--從查詢結果可以知道,oracle果然沒有為DBA_TAB_MODIFICATIONS建立公用同義詞。為sys.DBA_TAB_MODIFICATIONS建立一個同義詞即可。
SQL> conn sys/space6212 as sysdba
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as SYS
SQL> create public synonym DBA_TAB_MODIFICATIONS for sys.DBA_TAB_MODIFICATIONS;
Synonym created
SQL> conn suk/suk
Connected to Oracle9i Enterprise Edition Release 9.2.0.1.0
Connected as suk
SQL> select * from dba_tab_modifications;
TABLE_OWNER TABLE_NAME PARTITION_NAME SUBPARTITION_NAME INSERTS UPDATES DELETES TIMESTAMP TRUNCATED
------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------- ---------- ---------- ----------- ---------
SSK ITEM 0 889328 0 2006-7-19 1 NO
SSK PROCEDURE_ERR_RECORD 8 0 0 2006-7-19 1 NO
SUK CATEGORY 0 0 1 2006-8-8 13 NO
SUK ITEM 0 0 215 2006-8-8 13 NO
SUK PLAN_TABLE 84 0 84 2006-9-18 1 NO
SUK T 0 2 0 2006-9-19 1 YES
6 rows selected
感謝老和尚的提醒!
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/231499/viewspace-63728/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【MySQL】檢視&子查詢MySql
- navicat 新建查詢報錯
- elasticSearch head 查詢報錯Elasticsearch
- SQLServer通過連結伺服器查詢檢視報錯 “訊息 7347,級別 16”SQLServer伺服器
- OushuDB 檢視查詢執行情況
- 【PDB】Oracle跨PDB檢視查詢Oracle
- MySQL 查詢的成本的檢視MySql
- 【SQL】Oracle查詢轉換之物化檢視查詢重寫SQLOracle
- 檢視 Laravel 查詢資料語句Laravel
- [20210418]查詢v$檢視問題.txt
- MySQL查詢取別名報錯MySql
- 在KYLIN中執行查詢報錯
- oracle資料庫sql查詢檢視第二次查詢很慢Oracle資料庫SQL
- 如何使用SQL查詢檢視,Postico使用技巧分享~SQL
- 【SQL】Oracle查詢轉換之檢視合併SQLOracle
- 連線資料後,當執行查詢語句報錯:ORA-01219: 資料庫未開啟: 僅允許在固定表/檢視中查詢資料庫
- ef8 Contains 查詢條件 報錯 $ 附近錯誤AI
- Redis客戶端基本操作以及檢視慢查詢Redis客戶端
- Laravel 中 sql 查詢 使用 group by 報錯問題。LaravelSQL
- yarn應用程式安裝後,報錯檢查Yarn
- mysql查詢優化檢查 explainMySql優化AI
- 檢視ip地址的cmd命令 cmd查詢ip地址命令
- 使用linq查詢報錯English Message : Join a needs to be the same as OrderBy it
- 20240712總結、檢視函式對映報錯函式
- Oracle 12CR2查詢轉換之檢視合併Oracle
- 日誌查詢錯誤
- SAP QM 檢驗批上各個MIC質檢結果的查詢報表?
- MySQL Case-information_schema檢視查詢慢處理一例MySqlORM
- delphi 查詢av錯誤地址
- python實現查詢糾錯Python
- 複雜SQL查詢和視覺化報表構建SQL視覺化
- SpringMVC 檢視解析出錯SpringMVC
- 統計資訊查詢檢視|全方位認識 sys 系統庫
- linux命令檢視記憶體命令free -h whereis locate find查詢命令Linux記憶體
- Laravel ORM SQL 語句查詢、檢視,附贈 IDE ORM 語法提示LaravelORMSQLIDE
- Laravel-查詢-ONLY_FULL_GROUP_BY SQL 模式-報錯限制-解決LaravelSQL模式
- 【YashanDB知識庫】oracle dblink varchar型別查詢報錯記錄Oracle型別
- Dynamics CRM 通過配置來設定查詢欄位的預設檢視