Skip to content

Instantly share code, notes, and snippets.

@mtcoffee
Created September 8, 2017 18:12
Show Gist options
  • Save mtcoffee/038c5794ac1b70825fd2c902e8b9665e to your computer and use it in GitHub Desktop.
Save mtcoffee/038c5794ac1b70825fd2c902e8b9665e to your computer and use it in GitHub Desktop.
PL/SQL Script to delete all public synonyms for a schema
SET serveroutput ON
BEGIN
FOR cur_syn IN (SELECT synonym_name
FROM all_synonyms
WHERE table_owner = upper('schema_user'))
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;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment