Menu
Amazon Redshift
Database Developer Guide (API Version 2012-12-01)

DROP SCHEMA

Deletes a schema. This command is not reversible.

Syntax

Copy
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

Parameters

IF EXISTS

Clause that indicates that if the specified schema doesn’t exist, the command should make no changes and return a message that the schema doesn't exist, rather than terminating with an error.

This clause is useful when scripting, so the script doesn’t fail if DROP SCHEMA runs against a nonexistent schema.

name

Name of the schema to drop.

CASCADE

Keyword that indicates to automatically drop all objects in the schema, such as tables and functions.

RESTRICT

Keyword that indicates not to drop the schema if it contains any objects. This action is the default.

Example

The following example deletes a schema named S_SALES. This example uses RESTRICT as a safety mechanism so that the schema will not be deleted if it contains any objects. In this case, you would need to delete the schema objects before deleting the schema:

Copy
drop schema s_sales restrict;

The following example deletes a schema named S_SALES and all objects that depend on that schema:

Copy
drop schema s_sales cascade;

The following example either drops the S_SALES schema if it exists, or does nothing and returns a message if it does not:

Copy
drop schema if exists s_sales;