Created
March 30, 2021 04:59
-
-
Save sae13/28b908480c03abdf36a04c1f3070cd10 to your computer and use it in GitHub Desktop.
delete all tables in postgreSQL
This file contains hidden or 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 | |
q record | |
begin | |
for q in SELECT 'drop table ' || tablename query | |
FROM pg_catalog.pg_tables | |
WHERE schemaname != 'pg_catalog' AND | |
schemaname != 'information_schema' | |
loop execute immediate q.query; | |
end loop | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment