Last active
December 10, 2021 16:21
PostgreSQL: Drop all schemas
This file contains hidden or 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