Contents
DROP SCHEMA
A DDL command for removing a schema
DROP SCHEMA
is a DDL command for removing a schema.
DROP SCHEMA
was added in PostgreSQL 7.3.
Change history
- PostgreSQL 8.2
DROP SCHEMA IF EXISTS ...
syntax added (commit daea4d8e)
- PostgreSQL 7.3
- added (initial commit 11333426)
Examples
Dropping an empty schema:
postgres=# CREATE SCHEMA foo; CREATE SCHEMA postgres=# DROP SCHEMA foo; DROP SCHEMA
Dropping a non-empty schema:
postgres=# CREATE SCHEMA foo; CREATE SCHEMA postgres=# CREATE TABLE foo.bar (id INT, val TEXT); CREATE TABLE postgres=# DROP SCHEMA foo; ERROR: cannot drop schema foo because other objects depend on it DETAIL: table foo.bar depends on schema foo HINT: Use DROP ... CASCADE to drop the dependent objects too. postgres=# DROP SCHEMA foo CASCADE; NOTICE: drop cascades to table foo.bar DROP SCHEMA
References
- PostgreSQL documentation: DROP SCHEMA