All Products
Search
Document Center

DROP SCHEMA

Last Updated: Apr 24, 2019

Delete schemas

Syntax

  1. DROP {DATABASE | SCHEMA}
  2. [IF EXISTS]
  3. database_name
  4. [RESTRICT|CASCADE]

Parameters

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

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

Example

  1. mysql> show tables;
  2. +----------------------+
  3. | TABLE_NAME |
  4. +----------------------+
  5. | nation_text_string |
  6. | primitives_parquet_p |
  7. +----------------------+
  8. 2 rows in set (0.04 sec)
  9. mysql> drop database myfirstdb;
  10. ERROR 18802 (HY000): DropOperationFailedException: Cannot drop non-empty database.
  1. mysql> drop database myfirstdb cascade;
  2. Query OK, 0 rows affected (0.94 sec)