Skip to content

Instantly share code, notes, and snippets.

@jarrensj
Created September 23, 2025 05:04
Show Gist options
  • Select an option

  • Save jarrensj/b22b01a117780f1caed7f580ed25501d to your computer and use it in GitHub Desktop.

Select an option

Save jarrensj/b22b01a117780f1caed7f580ed25501d to your computer and use it in GitHub Desktop.
-- Drops all tables in the public schema
DO $$
DECLARE
table_name text;
BEGIN
FOR table_name IN
SELECT tablename
FROM pg_tables
WHERE schemaname = 'public'
LOOP
EXECUTE format('DROP TABLE IF EXISTS %I CASCADE;', table_name);
END LOOP;
END $$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment