是否可以使用 MergeTree 引擎更新 clickhouse 中的主键?
Is it possible to update primary key in clickhouse using MergeTree engine?
我正在尝试更新简单的主键 table。
当我这样执行查询时:
alter table test update id = 2 where id = 1;
我看到消息:
Cannot UPDATE key column `id`
有什么解决方法吗?
没有。作为一种解决方法,您需要将主键更改为不需要更新的不同列。这无法就地完成,因此您需要使用适当的主键创建新的 table,然后通过 INSERT+SELECT 或 clickhouse-copier.
迁移数据
我正在尝试更新简单的主键 table。
当我这样执行查询时:
alter table test update id = 2 where id = 1;
我看到消息:
Cannot UPDATE key column `id`
有什么解决方法吗?
没有。作为一种解决方法,您需要将主键更改为不需要更新的不同列。这无法就地完成,因此您需要使用适当的主键创建新的 table,然后通过 INSERT+SELECT 或 clickhouse-copier.
迁移数据