DROP DATABASE

DROP DATABASE 语句用于永久删除指定的数据库,以及删除所有在 schema 中创建的表和视图。与被删数据库相关联的用户权限不受影响。

语法图

DropDatabaseStmt

DROP DATABASE - 图1

IfExists

DROP DATABASE - 图2

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

示例

  1. SHOW DATABASES;
  1. +--------------------+
  2. | Database |
  3. +--------------------+
  4. | INFORMATION_SCHEMA |
  5. | PERFORMANCE_SCHEMA |
  6. | mysql |
  7. | test |
  8. +--------------------+
  9. 4 rows in set (0.00 sec)
  1. DROP DATABASE test;
  1. Query OK, 0 rows affected (0.25 sec)
  1. SHOW DATABASES;
  1. +--------------------+
  2. | Database |
  3. +--------------------+
  4. | INFORMATION_SCHEMA |
  5. | PERFORMANCE_SCHEMA |
  6. | mysql |
  7. +--------------------+
  8. 3 rows in set (0.00 sec)

MySQL 兼容性

DROP DATABASE 语句与 MySQL 完全兼容。如发现任何兼容性差异,请在 GitHub 上提交 issue

另请参阅