DROP DATABASE

Syntax

DROP DATABASE database_name;

Description

Drops an existing Database. It can only be executed by the Database owner. A Database cannot be dropped if it contains any non-empty schemas.

DROP DATABASE cannot be undone. Use it with care!

If the user's current Database is dropped, a new Database will need to be set for the ongoing sessions. See USE.

Arguments

database_name

The name of the Database to drop. For case-sensitive names, the name must be wrapped in double quotes, otherwise, the lowercased name will be used.

Examples

Drop a Database

The following shows how to drop the Database named DemoDB:

db.public/<no-store># LIST DATABASES;
   Name  | Default |  Owner   |      Created at      |      Updated at
---------+---------+----------+----------------------+-----------------------
  DemoDB |         | sysadmin | 2024-06-06T21:40:50Z | 2024-06-06T21:40:50Z
  db     |        | sysadmin | 2024-06-06T21:40:43Z | 2024-06-06T21:40:43Z
db.public/<no-store># DROP DATABASE "DemoDB";
db.public/<no-store># LIST DATABASES;
  Name | Default |  Owner   |      Created at      |      Updated at
-------+---------+----------+----------------------+-----------------------
  db   |        | sysadmin | 2024-06-06T21:40:43Z | 2024-06-06T21:40:43Z

Last updated