列操作中的 ClickHouse 限制

ClickHouse limitations in column manipulation

我在 CH 文档中发现列操作有一些限制。

For tables that don’t store data themselves (such as Merge and Distributed), ALTER just changes the table structure, and does not change the structure of subordinate tables. For example, when running ALTER for a Distributed table, you will also need to run ALTER for the tables on all remote servers.

这里我有问题..你有一些自动解决运行的方法吗?我在容器上创建了 4 个服务器,我不想在每个服务器上登录并手动执行命令,如 ALTER ... itd。

Hmm 只需公开端口并编写可以通过每个容器和 运行 命令的脚本。 ?

在Python ClickHouse中有驱动。

from clickhouse_driver import Client
client = Client('localhost', port=8090, user='admin', password='admin')

并在端口上迭代。

运行 ALTER TABLE db.table ADD COLUMN ... ON CLUSTER 'cluster-name'

第一部分为基础 Engine=ReplicatedMergeTree(...) table,第二部分为 Engine=Distributed(...) table