DROP SCHEMA

Permanently removes a schema from the database. Be sure that you want to remove the schema before you drop it, because DROP SCHEMA is an irreversible process. Use the CASCADE parameter to drop a schema containing one or more objects.

Syntax

DROP SCHEMA schema[,...] [ CASCADE | RESTRICT ]

Parameters

schema Name of the schema to drop.
CASCADE

Specifies to drop the schema and all objects in it, regardless of who owns those objects.

Caution: Objects in other schemas that depend on objects in the dropped schema—for example, user-defined functions—also are silently dropped.

RESTRICT Drops the schema only if it is empty (default).

Privileges

Schema owner

Restrictions

Examples

The following example drops schema S1 only if it doesn't contain any objects:

=> DROP SCHEMA S1;

The following example drops schema S1 whether or not it contains objects:

=> DROP SCHEMA S1 CASCADE;