Help Center > > Developer Guide> SQL Reference> SQL Syntax> DROP SCHEMA

DROP SCHEMA

Updated at: Mar 13, 2020 GMT+08:00

Function

DROP SCHEMA deletes a schema in a database.

Precautions

Only a schema owner or a system administrator can run the DROP SCHEMA command.

Syntax

DROP SCHEMA [ IF EXISTS ] schema_name [, ...] [ CASCADE | RESTRICT ];

Parameter Description

  • IF EXISTS

    Sends a notice instead of an error if the specified schema does not exist.

  • schema_name

    Specifies the name of a schema.

    Value range: An existing schema name.

  • CASCADE | RESTRICT
    • CASCADE: automatically deletes all objects that are contained in the schema to be deleted.
    • RESTRICT: refuses to delete the schema that contains any objects. This is the default.

Do not delete the schemas with the beginning of pg_temp or pg_toast_temp. They are internal system schemas, and deleting them may cause unexpected errors.

A user cannot delete the schema in use. To delete the schema in use, switch to another schema.

Examples

See Examples in CREATE SCHEMA.

Helpful Links

ALTER SCHEMA, CREATE SCHEMA

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel