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      |  Is Default |  Owner     |  Created At                   |
+============+=============+============+===============================+
| mydb       | true        | sysadmin   | 2023-08-09 17:14:46 +0000 UTC |
+------------+-------------+------------+-------------------------------+
| DemoDB     | false       | sysadmin   | 2024-07-02 16:24:11 +0000 UTC |
+------------+-------------+------------+-------------------------------+
db.public/<no-store># DROP DATABASE "DemoDB";
db.public/<no-store># LIST DATABASES;
+------------+-------------+------------+-------------------------------+
|  Name      |  Is Default |  Owner     |  Created At                   |
+============+=============+============+===============================+
| mydb       | true        | sysadmin   | 2023-08-09 17:14:46 +0000 UTC |
+------------+-------------+------------+-------------------------------+

Last updated