Updated on 2025-10-23 GMT+08:00

DROP DATABASE

Description

In M-compatible databases, DATABASE and SCHEMA are synonyms. Deleting a database is deleting a schema.

Precautions

  • Only the database owner or a user granted with the DROP permission can run the DROP DATABASE command. The system administrator has this permission by default.
  • Users except the initial user and O&M administrator cannot drop the database of the O&M administrator.
  • DROP DATABASE cannot be undone.
  • Schemas beginning with pg_temp or pg_toast_temp are for internal use. Do not delete them. Otherwise, unexpected consequences may be incurred.

Syntax

DROP DATABASE [ IF EXISTS ] database_name;

Parameters

  • IF EXISTS

    Reports a notice instead of an error if the specified database or schema does not exist.

  • database_name

    Specifies the name of the database or schema to be deleted.

    Value range: an existing database name

Examples

See Examples in section "CREATE DATABASE."

Helpful Links

ALTER DATABASE and CREATE DATABASE