Created
February 26, 2018 00:27
-
-
Save junalmeida/5d7f16822adcf09a58a0c7f19dd81268 to your computer and use it in GitHub Desktop.
Create Public Synonims (PL-SQL)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set serveroutput on | |
DECLARE | |
sql_txt VARCHAR2(300); | |
CURSOR obj_cur IS | |
SELECT object_name, owner FROM ALL_OBJECTS where owner IN ('<owner1>', '<owner2>') and object_type in ('TABLE', 'SEQUENCE', 'VIEW'); | |
BEGIN | |
dbms_output.enable(10000000); | |
FOR obj IN obj_cur LOOP | |
sql_txt:='CREATE OR REPLACE PUBLIC SYNONYM ' || obj.object_name || ' FOR ' || obj.owner || '.' || obj.object_name || ';'; | |
dbms_output.put_line(sql_txt); | |
--execute immediate sql_txt; --uncomment if you want to execute immediately | |
END LOOP; | |
END; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment