DROP SCHEMA语法

删除Schema

语法

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

参数

  • RESTRICT:如果该database不为空(有表存在),DROP操作会报错,执行失败,RESTRICT是默认逻辑。

  • CASCADE:即使该database不为空(有表存在),DROP也会级联删除下面的所有表。

示例

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)