![]() ![]() Target_schema VARCHAR2(256) := 'EMPIK_PORTAL_BETA_1' ĮXECUTE IMMEDIATE 'CREATE or REPLACE SYNONYM '|| target_schema|| '.' Or you can create pl/sql code using these tables desc dba_synonyms ![]() I think if you removed the OR REPLACE keyword it will prompt you that it exist All objects will be upper-cased automatically so you don't need the ". Oracle can have cased objects, but it is very, very rarely worth the hassle. On a slightly separate not please do not quote your object names. DDL has to be done inside execute immediate in a block.Įxecute immediate 'CREATE OR REPLACE SYNONYM ETKS_PR_RW.SQ_CLDOS_ATCHMNT_IDįOR CLDOS_ONLINE_DBA.SQ_CLDOS_ATCHMNT_ID' If you want to combine these into a single block then you can do something like this: declare select *Īnd synonym_name = 'SQ_CLDOS_ATCHMNT_ID' Query the data-dictionary, as you're in multiple schemas all_synonyms seems like the best bet. The statement will throw an error if the synonym already exists and won't get over-written. However, if you do want to there are a couple of options: You should always know what all of your objects are and where the synonyms point. If your database is organised well this shouldn't happen. The only reason to be wary of using replace is if you might have a different synonym with the same name. You will over-write whatever synonym existed with the previous name. As you're using the replace keyword there is no need to check whether the synonym exists first. ![]()
0 Comments
Leave a Reply. |