Syntax

DROP SCHEMA [ IF EXISTS ] [database_name.]schema_name [ CASCADE ];

Parameters

Parameter or clauseDescription
IF EXISTS clauseDo not return an error if the specified schema does not exist.
database_nameSpecify the name of a database to remove the schema in that database. You can use SHOW DATABASES to get a list of all available databases. If you don’t specify a database, the specified schema in the default database will be removed.
schema_nameThe name of the schema you want to remove. The default schema is public. You can use SHOW SCHEMAS to get a list of all available schemas.
CASCADEAutomatically drops the schema’s dependent objects (tables, materialized views, etc.) and any objects that depend on those objects.

Examples

This statement removes the rw_schema schema from the rw_db database:

DROP SCHEMA rw_db.rw_schema;

This statement removes the rw_schema schema from the dev database (default database):

DROP SCHEMA rw_schema;

Use this statement to avoid an error if the schema does not exist:

DROP SCHEMA IF EXISTS rw_schema;

This statement removes the rw_schema schema and everything it contains from the database:

DROP SCHEMA rw_schema CASCADE;