Skip to content

Latest commit

 

History

History
74 lines (55 loc) · 1.43 KB

sql-statement-drop-database.md

File metadata and controls

74 lines (55 loc) · 1.43 KB
title summary aliases
DROP DATABASE
TiDB 数据库中 DROP DATABASE 的使用概况。
/docs-cn/dev/sql-statements/sql-statement-drop-database/
/docs-cn/dev/reference/sql/statements/drop-database/

DROP DATABASE

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

语法图

DropDatabaseStmt ::=
    'DROP' 'DATABASE' IfExists DBName

IfExists ::= ( 'IF' 'EXISTS' )?

示例

{{< copyable "sql" >}}

SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| PERFORMANCE_SCHEMA |
| mysql              |
| test               |
+--------------------+
4 rows in set (0.00 sec)

{{< copyable "sql" >}}

DROP DATABASE test;
Query OK, 0 rows affected (0.25 sec)

{{< copyable "sql" >}}

SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| INFORMATION_SCHEMA |
| PERFORMANCE_SCHEMA |
| mysql              |
+--------------------+
3 rows in set (0.00 sec)

MySQL 兼容性

DROP DATABASE 语句与 MySQL 完全兼容。如发现任何兼容性差异,请尝试 TiDB 支持资源

另请参阅