mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-06 15:42:39 +00:00
258d2fd499
* normalize
* split & adjust links
* re-normalize
* adjust ru links
* adjust ja/tr links
* partially apply e0d19d2aea
* reset contribs
22 lines
1.0 KiB
Markdown
22 lines
1.0 KiB
Markdown
---
|
|
toc_priority: 32
|
|
toc_title: Distributed DDL
|
|
---
|
|
|
|
# Distributed DDL Queries (ON CLUSTER Clause) {#distributed-ddl-queries-on-cluster-clause}
|
|
|
|
By default the `CREATE`, `DROP`, `ALTER`, and `RENAME` queries affect only the current server where they are executed. In a cluster setup, it is possible to run such queries in a distributed manner with the `ON CLUSTER` clause.
|
|
|
|
For example, the following query creates the `all_hits` `Distributed` table on each host in `cluster`:
|
|
|
|
``` sql
|
|
CREATE TABLE IF NOT EXISTS all_hits ON CLUSTER cluster (p Date, i Int32) ENGINE = Distributed(cluster, default, hits)
|
|
```
|
|
|
|
In order to run these queries correctly, each host must have the same cluster definition (to simplify syncing configs, you can use substitutions from ZooKeeper). They must also connect to the ZooKeeper servers.
|
|
|
|
The local version of the query will eventually be executed on each host in the cluster, even if some hosts are currently not available.
|
|
|
|
!!! warning "Warning"
|
|
The order for executing queries within a single host is guaranteed.
|