Description
You can execute the DROP DATABASE statement to delete a database.
Syntax
drop_database_stmt:
DROP DATABASE [IF EXISTS] database_name;
Parameters
| Parameter | Description |
|---|---|
| IF EXISTS | Prevent errors that occur when you attempt to delete a database that does not exist. |
| database_name | The name of the database that you want to delete. |
Examples
- Delete database test2.
OceanBase(admin@test)>drop database test2;
Query OK, 0 rows affected (0.03 sec)
- Delete database notest that does not exist.
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)