DROP SCHEMA

DROP SCHEMA can be used to remove a schema.

The schema has to be empty before removal.

Blue does not support dropping a schema with objects.

See also: CREATE SCHEMA, ALTER DEFAULT SCHEMA, and RENAME SCHEMA.

Permissions

The role must have the DDL permission at the database level.

Syntax

DROP SCHEMA <schema_name>

schema_name ::= identifier

Parameters

Parameter

Description

schema_name

The name of the schema to drop

Examples

Dropping a schema:

DROP SCHEMA sales;

Dropping a schema if it’s not empty:

If a schema contains several tables, BLUE will alert you that these tables need to be dropped first. This prevents accidental dropping of full schemas.

DROP SCHEMA sales;
Schema 'sales' contains the following objects:
Tables - 'sales.foo' , 'sales.bar'
Please drop its content and then try again.

To drop the schema, drop the schema’s tables first, and then drop the schema:

DROP TABLE sales.foo;

DROP TABLE sales.bar;

DROP SCHEMA sales;