DROP DATABASE

The DROP DATABASE statement permanently removes a specified database schema, and all of the tables and views that were created inside. User privileges that are associated with the dropped database remain unaffected.

Synopsis

DropDatabaseStmt

DROP DATABASE - 图1

IfExists

DROP DATABASE - 图2

  1. DropDatabaseStmt ::=
  2. 'DROP' 'DATABASE' IfExists DBName
  3. IfExists ::= ( 'IF' 'EXISTS' )?

Examples

  1. mysql> SHOW DATABASES;
  2. +--------------------+
  3. | Database |
  4. +--------------------+
  5. | INFORMATION_SCHEMA |
  6. | PERFORMANCE_SCHEMA |
  7. | mysql |
  8. | test |
  9. +--------------------+
  10. 4 rows in set (0.00 sec)
  11. mysql> DROP DATABASE test;
  12. Query OK, 0 rows affected (0.25 sec)
  13. mysql> SHOW DATABASES;
  14. +--------------------+
  15. | Database |
  16. +--------------------+
  17. | INFORMATION_SCHEMA |
  18. | PERFORMANCE_SCHEMA |
  19. | mysql |
  20. +--------------------+
  21. 3 rows in set (0.00 sec)

MySQL compatibility

The DROP DATABASE statement in TiDB is fully compatible with MySQL. If you find any compatibility differences, report a bug.

See also