Created
July 5, 2018 08:52
-
-
Save tonyyates/dd3660edd58aaa658f46282376516d6e to your computer and use it in GitHub Desktop.
drop all tables in a postgres database
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
DO $$ DECLARE | |
tabname RECORD; | |
BEGIN | |
FOR tabname IN (SELECT tablename | |
FROM pg_tables | |
WHERE schemaname = current_schema()) | |
LOOP | |
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(tabname.tablename) || ' CASCADE'; | |
END LOOP; | |
END $$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment