DROP SCHEMA

DROP SCHEMA — remove a schema

Syntax

DROP SCHEMA name [ CASCADE | RESTRICT ] [ IF EXISTS ]
DROP SCHEMA [ CASCADE | RESTRICT] [ IF EXISTS ] name

Description

DROP SCHEMA removes schemas from the database.
Refer to CREATE SCHEMA for information on how to create a schema.

Parameters

Example

Create objects in a schema. Drop the schema.

USE SCHEMA schema1
CREATE DOMAIN schema1.test_domain INTEGER;
CREATE TABLE schema1.test_table (column1 test_domain);
 
DROP SCHEMA schema1;
schema "SCHEMA1" has 1 domain, 0 sequences, 0 roles, and 0 procedures.  CASCADE will drop all
 
DROP SCHEMA schema1 CASCADE;

Dropping a Non-Empty Schema

DROP SCHEMA PROD;

When dropping a non-empty schema the following error message is displayed:

schema "PROD" is not empty and cannot be dropped, it has 0 domains, 2 sequences, 0 roles, 0 procedures and 0 functions. CASCADE option can be used to forcibly drop the schema and all related content.