clickhouse readonly corresponding
时间: 2023-08-31 10:05:51 浏览: 112
ClickHouse supports the creation of read-only replicas of the primary cluster. These replicas can be used for read-heavy workloads to offload traffic from the primary cluster and improve query performance. To create a read-only replica, you can use the `REPLICA` keyword in the `CREATE TABLE` statement. For example:
```
CREATE TABLE my_table ON CLUSTER my_cluster
(
...
) ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/my_table', '{replica}')
PARTITION BY ...
ORDER BY ...
SETTINGS ...
PRIMARY KEY ...
REPLICA READONLY;
```
In the above example, the `REPLICA READONLY` clause creates a read-only replica of the table `my_table` on the cluster `my_cluster`. The replica is stored on the same file system as the primary cluster, but it cannot accept any write operations.
阅读全文