DROP DATABASE

更新时间:
复制 MD 格式

Use the DROP DATABASE statement to delete a database.

Syntax

DROP DATABASE [IF EXISTS] database_name;

Parameters

ParameterDescription
IF EXISTSSuppresses the error that occurs when you try to drop a database that does not exist. A warning is generated instead.
database_nameThe name of the database to drop.

Examples

Drop a database named customer:

DROP DATABASE customer;

Output:

Query OK, 0 rows affected (0.03 sec)

Use IF EXISTS to suppress the error when dropping a database that does not exist. A warning is generated instead:

DROP DATABASE IF EXISTS customer;

Output:

Query OK, 0 rows affected, 1 warning (0.00 sec)