Skip to content

Instantly share code, notes, and snippets.

@alevgenk
Last active December 9, 2019 09:20
Show Gist options
  • Save alevgenk/55c9f914933d5a4e7efc57e2afc41ce9 to your computer and use it in GitHub Desktop.
Save alevgenk/55c9f914933d5a4e7efc57e2afc41ce9 to your computer and use it in GitHub Desktop.
Drop tables in Postgres database
DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) 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