Skip to main content
Deletes a schema from the current database.

Syntax

DROP SCHEMA [IF EXISTS] <schema_name> [CASCADE | RESTRICT]

Parameters

ParameterDescription
<schema_name>The name of the schema to delete.
IF EXISTSPrevents an error if the schema does not exist. Without this clause, the statement fails if the schema is missing.
CASCADEDrops the schema and all objects it contains, including tables, views, and aggregating indexes.
RESTRICTPrevents the schema from being dropped if it contains any objects. This is the default behavior.

Examples

Drop an empty schema
DROP SCHEMA staging;
Drop a schema only if it exists
DROP SCHEMA IF EXISTS staging;
Drop a schema and all its objects
DROP SCHEMA analytics CASCADE;
Prevent dropping a schema that contains objects The following statement fails if the analytics schema contains any tables, views, or other objects:
DROP SCHEMA analytics RESTRICT;