Last active
December 10, 2021 16:21
-
-
Save nuclearglow/ef34a40a1c1ab95bf0ddb5410650b6a3 to your computer and use it in GitHub Desktop.
PostgreSQL: Drop all schemas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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