for public synonym, only sys user can compile it?
Only sys user can compile public synonym:
[@more@]Oracle 中的同義詞是schema 物件的一個別名。同義詞分為公共(public)同義詞和私有(private)同義詞.公共同義詞可以被所有資料庫使用者所訪問,而私有同義詞只能被owner和被授權使用者訪問。
同義詞可以不依賴於引用的物件單獨存在,所以我們可以修改同義詞所應用的物件,而後只需要重新定義(刪除重建,同義詞不可以透過ALTER 語法來重新定義)同義詞就可以,這樣可以降低應用程式的複雜性。當同義詞被刪除後所有被同義詞應用的物件(當然TABLE 之類就除外了)將變成INVALID。
當然如果你刪除或修改了某個同義詞所引用的物件,同義詞也會變成INVALID,當然我們不需要去手動compile同義詞,當程式下次訪問的時候,同義詞自動會變成VALID,只要同義詞所引用的物件沒有錯誤就可以。當然,如果你願意你也可以使用ALTER (PUBLIC) SYNONYM語句手工編譯同義詞,注意,這裡你只能使用sys user或者owner來編譯private同義詞。而public同義詞只能用sys user來編譯了。對於非owner或者其他任何使用者,都會收到ORA-01031: insufficient privilege錯誤。
下面來實驗一下:
SQL> conn hr/hr 已連線。 SQL> CREATE synonym syn_jobs FOR jobs; 同義詞已建立。 SQL> ALTER synonym syn_jobs compile; 同義詞已變更。 SQL> conn /AS sysdba 已連線。 SQL> ALTER synonym syn_jobs compile; ALTER synonym syn_jobs compile * 第 1 行出現錯誤: ORA-00942: 表或檢視不存在 SQL> ALTER synonym hr.syn_jobs compile; 同義詞已變更。 SQL> CREATE public synonym syn_p_jobs FOR hr.jobs; 同義詞已建立。 SQL> ALTER synonym syn_p_jobs compile; ALTER synonym syn_p_jobs compile * 第 1 行出現錯誤: ORA-00942: 表或檢視不存在 SQL> ALTER public synonym syn_p_jobs compile; 同義詞已變更。 SQL> conn system/system; 已連線。 SQL> ALTER public synonym syn_p_jobs compile; ALTER public synonym syn_p_jobs compile * 第 1 行出現錯誤: ORA-01031: 許可權不足 SQL> ALTER synonym hr.syn_jobs compile; ALTER synonym hr.syn_jobs compile * 第 1 行出現錯誤: ORA-01031: 許可權不足 SQL> CREATE user syn_user IDENTIFIED BY synuser 2 DEFAULT tablespace users 3 TEMPORARY tablespace temp; 使用者已建立。 SQL> conn /AS sysdba 已連線。 SQL> GRANT sysdba TO syn_user; 授權成功。 SQL> GRANT dba TO syn_user; 授權成功。 SQL> GRANT ALL ON hr.jobs TO syn_user; 授權成功。 SQL> conn syn_user/synuser; 已連線。 SQL> ALTER synonym hr.syn_jobs compile; ALTER synonym hr.syn_jobs compile * 第 1 行出現錯誤: ORA-01031: 許可權不足 SQL> ALTER public synonym syn_p_jobs compile; ALTER public synonym syn_p_jobs compile * 第 1 行出現錯誤: ORA-01031: 許可權不足
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/14377/viewspace-1011302/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Synonym_View_Materialized和Public物件ViewZed物件
- Can one rename a database user (schema)?Database
- 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
- "Only fullscreen opaque activities can request orientation "問題再分析Opaque
- Enterprise Instant Messenger: Are you the only user?Messenger
- "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
- Android8.0適配-Only fullscreen opaque activities can request orientationAndroidOpaque
- mysql can't connect error about privilege----not root userMySqlError
- No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_Compile
- monitor sys and system user(轉自http://www.oracle.com)HTTPOracle
- 解決Android 8 0的Only fullscreen opaque activities can request orientatioAndroidOpaque
- ORA-02030: can only select from fixed tables/viewsView
- GCC編譯遇到“a label can only be part of a statement and a declaration is not a statement”問題GC編譯
- DIA-48449: Tail alert can only apply to single ADR homeAIAPP
- Oracle synonym 相關Oracle
- espcms /public/class_connector.php intval truncation Vul Arbitrary User LoginPHP
- Oracle SYS使用者無法設定session級別的read onlyOracleSession
- [20190423]簡單測試user和SYS_CONTEXT ('USERENV','CURRENT_USER').txtContext
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- 使用monaco編輯器 報錯Can only have one anonymous define call per script file
- Oracle9i sys登入後通過public同義詞move table報錯Oracle
- mysql啟動時報錯Can't read from messagefile errmsg.sysMySql
- Connection to host as user root failed.ERROR: NMO not setuid-root (Unix-only)AIErrorUI
- 解決Error (1133): Can’t find any matching row in the user tableError
- 【React】Invalid hook call. Hooks can only be called inside of the body of a function component.ReactHookIDEFunction
- Can GoldenGate Replicate An Oracle Table That Contains Only CLOB Column(s)? (Doc ID 971833.1)GoOracleAI
- MySQl報錯之@@GLOBAL.GTID_PURGED can only be set when @@GLOBAL.GTID_MODE = ONMySql
- IMP-00013: only a DBA can import a file exported by another DBA 問題及解決方案ImportExport
- PostgreSQLOracle相容性-synonym匿名SQLOracle
- 詳解同義詞(synonym)
- Check the existence of public synonyms Remove the public synonymsREM
- ld: -pie can only be used when targeting iOS 4.2 or later clang: error: linker command failed with eiOSErrorAI
- ERROR 1840 (HY000) at line 24: @@GLOBAL.GTID_PURGED can only be set when @@GLOBAError