Skip to content

Instantly share code, notes, and snippets.

@sae13
Created March 30, 2021 04:59
Show Gist options
  • Save sae13/28b908480c03abdf36a04c1f3070cd10 to your computer and use it in GitHub Desktop.
Save sae13/28b908480c03abdf36a04c1f3070cd10 to your computer and use it in GitHub Desktop.
delete all tables in postgreSQL
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