格式
DROP DATABASE [IF EXISTS] dbname;
DROPDATABASE 用于取消数据库中的所用表格和取消数据库。IF EXISTS
用于防止当数据库不存在时发生错误。
示例
mysql> drop database notest;
ERROR 1008 (HY000): Can't drop database 'notest'; database doesn't exist
mysql> drop database if exists notest;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show warnings;
+-------+------+------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------+
| Note | 1008 | Can't drop database 'notest'; database doesn't exist |
+-------+------+------------------------------------------------------+
1 row in set (0.00 sec)
报错
语法错误时,报
ERROR 1064 (42000): You have an error in your SQL syntax;
数据库不存在,报
ERROR 1008 (HY000): Can't drop database 'XXX'; database doesn't exist;