描述
DROP DATABASE 用于删除数据库。
格式
drop_database_stmt:
DROP DATABASE [IF EXISTS] database_name;
参数解释
参数 | 描述 |
IF EXISTS | 用于防止当数据库不存在时发生错误。 |
database_name | 指定待删除的数据库名。 |
示例
- 删除数据库 test2。
OceanBase(admin@test)>drop database test2;
Query OK, 0 rows affected (0.03 sec)
- 删除不存在的数据库 notest。
OceanBase(admin@test)>drop database notest;
ERROR 1008 (HY000): Can't drop database 'notest'; database doesn't exist
OceanBase(admin@test)>drop database if exists notest;
Query OK, 0 rows affected, 1 warning (0.00 sec)
OceanBase(admin@test)>show warnings;
+-------+------+------------------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------------------+
| Note | 1008 | Can't drop database 'notest'; database doesn't exist |
+-------+------+------------------------------------------------------+
1 row in set (0.00 sec)