mysql删除数据库

命令:

drop database <数据库名>

复制

例如:删除名为 xhkdb的数据库

drop database xcx_sjkj;

复制

例子1:删除一个已经确定存在的数据库

drop database drop_database;

复制

Query OK, 0 rows affected (0.00 sec)

例子2:删除一个不确定存在的数据库

drop database drop_database;

复制

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

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

drop database if exists drop_database;

复制

Query OK, 0 rows affected, 1 warning (0.00 sec)//产生一个警告说明此数据库不存在

 create database drop_database;

复制

Query OK, 1 row affected (0.00 sec)

 drop database if exists drop_database;//if exists 判断数据库是否存在,不存在也不产生错误

复制

Query OK, 0 rows affected (0.00 sec)

你可能感兴趣的