删除MySQL数据库

来源:互联网 发布:淘宝促销模板代码 编辑:程序博客网 时间:2024/05/01 05:14

1、创建数据库

mysql> create database drop_database;
Query OK, 1 row affected (0.00 sec)

2、删除一个已经确定存在的数据库

mysql> drop database drop_database;
Query OK, 0 rows affected (0.00 sec)

3、删除一个不确定存在的数据库

mysql> drop database drop_database;
ERROR 1008 (HY000): Can't drop database 'drop_database'; database doesn't exist

//发生错误,不能删除'drop_database'数据库,该数据库不存在。

mysql> drop database if exists drop_database;
Query OK, 0 rows affected, 1 warning (0.00 sec)//产生一个警告说明此数据库不存在

mysql> create database drop_database;
Query OK, 1 row affected (0.00 sec)

mysql> drop database if exists drop_database;//if exists 判断数据库是否存在,不存在也不产生错误
Query OK, 0 rows affected (0.00 sec)

原创粉丝点击