How to recreate public synonym “DUAL”?

北城以北 提交于 2019-12-20 02:54:09

问题


Using SQLDeveloper 4.0.1.14 to create an export script (separate files & "drops" checked), it generated me those 4 lines among others in DROP.sql:

DROP SYNONYM "PUBLIC"."DUAL";
DROP SYNONYM "PUBLIC"."DBMS_SQL";
DROP SYNONYM "PUBLIC"."DBMS_LOCK";
DROP SYNONYM "PUBLIC"."DBMS_OUTPUT";

Now that I have accidentally passed the whole script using SYSTEM user, I can no longer do modification (create or drop tables) to the database, I have that error popping:

An error was encountered performing the requested operation:

ORA-00604: error occurred at recursive SQL level 1
ORA-00942: table or view does not exist
00604. 00000 -  "error occurred at recursive SQL level %s"
*Cause:    An error occurred while processing a recursive SQL statement
       (a statement applying to internal dictionary tables).
*Action:   If the situation described in the next error on the stack
       can be corrected, do so; otherwise contact Oracle Support.
Vendor code 604

The problem is that I'm getting that error event when I try this:

CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "SYS"."DUAL";

I precise that the SYS.DUAL table still exists as SELECT 1 FROM SYS.DUAL works but SELECT 1 FROM DUAL fails with ORA-00942: table or view does not exist.

I tried to recreate the synonym as SYSTEM and SYSDBA with the same failure.

Can I recreate those synonyms with another way?


回答1:


Try it as SYS but without the doauble quotes, i.e.:

CREATE OR REPLACE PUBLIC SYNONYM DUAL FOR SYS.DUAL;

not

CREATE OR REPLACE PUBLIC SYNONYM "DUAL" FOR "SYS"."DUAL";

As I understand it the double quotes make the object name case sensitive.

Update - If you have access to metalink then you will find the answer in note 973260.1, something aboput a trigger firing :

ALTER SYSTEM SET "_SYSTEM_TRIG_ENABLED"=FALSE SCOPE=MEMORY;
CREATE OR REPLACE PUBLIC SYNONYM DUAL FOR SYS.DUAL;
ALTER SYSTEM SET "_SYSTEM_TRIG_ENABLED"=true SCOPE=MEMORY;

The note suggest that if this doesnt work, query DBA_TRIGGERS to find a BEFORE CREATE trigger enabled, and if found disable it and then re-issue create synonym statement, then re-enable the trigger.



来源:https://stackoverflow.com/questions/30504918/how-to-recreate-public-synonym-dual

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!