Skip to main content

DROP DATABASE

Drops a database.


Syntax

DROP DATABASE [IF EXISTS] <name> [ WITH FORCE ]

Description

DROP DATABASE deletes all catalog entries of the database as well as the directory that contains the data. It cannot be undone. Use with caution.


Parameters

  • IF EXISTS

    If you include IF EXISTS in your statement, no error will be reported when the specified database does not exist. A notice will be issued instead.

  • <name>

    The name of the database.

  • WITH FORCE

    Specifies to forcibly drop the database, no matter whether anyone is connected to it. Without specifying this option, the database will fail to be dropped if anyone is connected to it.


Usage notes

DROP DATABASE cannot be run inside a transaction block.


Examples

Drop database testonly:

DROP DATABASE testonly;

SQL standard compatibility

Standard SQL does not support DROP DATABASE.