Created
October 20, 2015 14:00
-
-
Save brotherBear/9bbfc9e44e34b3fe1526 to your computer and use it in GitHub Desktop.
Oracle SQL - How to delete all public synonyms for a schema
This file contains 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
BEGIN | |
FOR cur_syn IN (SELECT synonym_name | |
FROM all_synonyms | |
WHERE table_owner = 'somebody') | |
LOOP | |
BEGIN | |
EXECUTE IMMEDIATE 'drop public synonym "' || cur_syn.synonym_name || '";'; | |
EXCEPTION | |
WHEN OTHERS | |
THEN | |
DBMS_OUTPUT.PUT_LINE ('Failed to drop the public synonym ' || cur_syn.synonym_name || '!'); | |
END; | |
END LOOP; | |
END; | |
/ |
Thanks, the link is broken now, so I made my version
https://gist.github.com/trang1/daff5c9fed567a46bbefad86e5e38d78#file-drop-public-synonyms-sql
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing. Was getting a syntax error so created a modified version here - https://gist.github.com/tremblam/038c5794ac1b70825fd2c902e8b9665e