All Products
Search
Document Center

DROP SCHEMA

Last Updated: Mar 22, 2021

Delete a schema

Syntax

DROP {DATABASE | SCHEMA} 
    [IF EXISTS] 
    database_name 
    [RESTRICT|CASCADE]

Parameters

  • RESTRICT: If the database contains tables, the DROP operation fails and the system returns an error. RESTRICT is the default logic.

  • CASCADE: Even if the database contains tables, the DROP operation deletes all tables cascaded in the database.

Example

mysql> show tables;
+----------------------+
| TABLE_NAME           |
+----------------------+
| nation_text_string   |
| primitives_parquet_p |
+----------------------+
2 rows in set (0.04 sec)

mysql> drop database myfirstdb;
ERROR 18802 (HY000): DropOperationFailedException:Can not drop non-empty database.
mysql> drop database myfirstdb cascade;
Query OK, 0 rows affected (0.94 sec)