Skip to content

Instantly share code, notes, and snippets.

@nuclearglow
Last active December 10, 2021 16:21
Show Gist options
  • Save nuclearglow/ef34a40a1c1ab95bf0ddb5410650b6a3 to your computer and use it in GitHub Desktop.
Save nuclearglow/ef34a40a1c1ab95bf0ddb5410650b6a3 to your computer and use it in GitHub Desktop.
PostgreSQL: Drop all schemas
DO $$ DECLARE
namespace RECORD;
BEGIN
FOR namespace IN (SELECT s.nspname as schema from pg_catalog.pg_namespace s where nspname not in ('information_schema', 'pg_catalog', 'public', 'everest') and nspname not like 'pg_%')
LOOP
EXECUTE 'DROP SCHEMA IF EXISTS ' || quote_ident(namespace.schema) || ' CASCADE';
END LOOP;
END $$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment