Skip to content

Instantly share code, notes, and snippets.

@ahmedivy
Last active August 3, 2024 08:18
Show Gist options
  • Save ahmedivy/3a9d408f8e87d75c164e786b454a26e2 to your computer and use it in GitHub Desktop.
Save ahmedivy/3a9d408f8e87d75c164e786b454a26e2 to your computer and use it in GitHub Desktop.
remove all postgres tables and data
do $$ declare
r record;
begin
for r in (select tablename from pg_tables where schemaname = 'my-schema-name') loop
execute 'drop table if exists ' || quote_ident(r.tablename) || ' cascade';
end loop;
end $$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment