Purpose
This statement is used to drop a database.
Syntax
DROP DATABASE [IF EXISTS] database_name
Parameters
Parameters |
Description |
|---|---|
| IF EXISTS | This is used to prevent errors when the database does not exist. |
| database_name | Specifies the name of the database to be dropped. |
Examples
Drop the database
test2.obclient> DROP DATABASE test2;Delete the non-existent database
notest.obclient> DROP DATABASE notest;Expected return value:
ERROR 1008 (HY000): Can't drop database 'notest'; database doesn't existobclient> DROP DATABASE IF EXISTS notest;Expected return result:
Query OK, 0 rows affected, 1 warningobclient> SHOW WARNINGS;Expected return value:
+-------+------+------------------------------------------------------+ | Level | Code | Message | +-------+------+------------------------------------------------------+ | Note | 1008 | Can't drop database 'notest'; database doesn't exist | +-------+------+------------------------------------------------------+ 1 row in set