Skip to content

Instantly share code, notes, and snippets.

@bobfang1992
Created August 13, 2020 08:59
Show Gist options
  • Save bobfang1992/7f5550f93d9c9f5053e37376b91b756c to your computer and use it in GitHub Desktop.
Save bobfang1992/7f5550f93d9c9f5053e37376b91b756c to your computer and use it in GitHub Desktop.
Delete every table in PG
DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'DROP TABLE ' || 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