说明
sql
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.02 sec)
数据库存在
删除报错
sql
mysql> drop database test;
ERROR 1008 (HY000): Can't drop database 'test'; database doesn't exist
解决方案
sql
drop database if exists test;