ClickHouse/docs/zh/sql-reference/statements/create/database.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
1005 B
Markdown
Raw Normal View History

2021-08-27 11:32:21 +00:00
---
2022-08-26 19:07:59 +00:00
slug: /zh/sql-reference/statements/create/database
2022-04-10 23:08:18 +00:00
sidebar_position: 35
sidebar_label: DATABASE
2021-08-27 11:32:21 +00:00
---
# 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}
2023-03-18 02:45:43 +00:00
[MySQL](../../../engines/database-engines/mysql.md) 允许您从远程MySQL服务器检索数据. 默认情况下ClickHouse使用自己的[database engine](../../../engines/database-engines/index.md). 还有一个[lazy](../../../engines/database-engines/lazy.md)引擎.