Skip to content

Instantly share code, notes, and snippets.

@brotherBear
Created October 20, 2015 14:00
Show Gist options
  • Save brotherBear/9bbfc9e44e34b3fe1526 to your computer and use it in GitHub Desktop.
Save brotherBear/9bbfc9e44e34b3fe1526 to your computer and use it in GitHub Desktop.
Oracle SQL - How to delete all public synonyms for a schema
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;
/
@mtcoffee
Copy link

mtcoffee commented Sep 8, 2017

Thanks for sharing. Was getting a syntax error so created a modified version here - https://gist.github.com/tremblam/038c5794ac1b70825fd2c902e8b9665e

@trang1
Copy link

trang1 commented Nov 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment