ClickHouse/docs/zh/sql-reference/statements/create/database.md
2023-03-17 21:45:43 -05:00

31 lines
1005 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
slug: /zh/sql-reference/statements/create/database
sidebar_position: 35
sidebar_label: DATABASE
---
# CREATE DATABASE {#query-language-create-database}
创建数据库.
``` sql
CREATE DATABASE [IF NOT EXISTS] db_name [ON CLUSTER cluster] [ENGINE = engine(...)]
```
## 条件 {#clauses}
### IF NOT EXISTS {#if-not-exists}
如果`db_name`数据库已经存在则ClickHouse不会创建新数据库并且
- 如果指定了子句,则不会引发异常。
- 如果未指定子句,则抛出异常。
### ON CLUSTER {#on-cluster}
ClickHouse在指定集群的所有服务器上创建`db_name`数据库。 更多细节在 [Distributed DDL](../../../sql-reference/distributed-ddl.md) article.
### ENGINE {#engine}
[MySQL](../../../engines/database-engines/mysql.md) 允许您从远程MySQL服务器检索数据. 默认情况下ClickHouse使用自己的[database engine](../../../engines/database-engines/index.md). 还有一个[lazy](../../../engines/database-engines/lazy.md)引擎.