Purpose
You can use this statement to drop a database.
Syntax
drop_database_stmt:
DROP DATABASE [IF EXISTS] database_name;
Parameters
| Parameter | Description |
|---|---|
| IF EXISTS | If this parameter is present, no error will be returned when the database does not exist. |
| database_name | The name of the database to be dropped. |
Examples
Drop the
test2database.obclient> DROP DATABASE test2; Query OK, 0 rows affectedDrop the
notestdatabase that does not exist.obclient> DROP DATABASE notest; ERROR 1008 (HY000): Can't drop database 'notest'; database doesn't exist obclient> DROP DATABASE IF EXISTS notest; Query OK, 0 rows affected, 1 warning obclient> SHOW WARNINGS; +-------+------+------------------------------------------------------+ | Level | Code | Message | +-------+------+------------------------------------------------------+ | Note | 1008 | Can't drop database 'notest'; database doesn't exist | +-------+------+------------------------------------------------------+ 1 row in set