Skip to content

Instantly share code, notes, and snippets.

@trang1
Created November 7, 2018 10:56
Show Gist options
  • Save trang1/daff5c9fed567a46bbefad86e5e38d78 to your computer and use it in GitHub Desktop.
Save trang1/daff5c9fed567a46bbefad86e5e38d78 to your computer and use it in GitHub Desktop.
Oracle PL/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 || '! ' || sqlerrm);
END;
END LOOP;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment