DROP DATABASE
Description
This statement is used to delete a database.
Syntax
drop_database_stmt:
DROP DATABASE [IF EXISTS] database_name;
Parameters
| Parameter | Description |
|---|---|
| IF EXISTS | Prevents an error when the database does not exist. |
| database_name | The name of the database to be deleted. |
Examples
-
Delete the
test2database.DROP DATABASE test2;
Query OK, 0 rows affected -
Delete the non-existent
notestdatabase.DROP DATABASE notest;
ERROR 1008 (HY000): Can't drop database 'notest'; database doesn't exist
DROP DATABASE IF EXISTS notest;
Query OK, 0 rows affected, 1 warning
SHOW WARNINGS;
+-------+------+------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------+
| Note | 1008 | Can't drop database 'notest'; database doesn't exist |
+-------+------+------------------------------------------------------+
1 row in set (0.001 sec)