Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to update primary key in clickhouse using MergeTree engine?

Tags:

clickhouse

I'm trying to update primary key in simple table.

When i execute the query like this:

alter table test update id = 2 where id = 1;

I see the message:

Cannot UPDATE key column `id`

Is there any workarounds about this?

like image 874
the_kaba Avatar asked Nov 15 '25 00:11

the_kaba


1 Answers

No. As a workaround you need to change primary key to different columns that don't need updating. This cannot be done in place, so you need to create new table with proper primary key and then migrate data via INSERT+SELECT or clickhouse-copier.

like image 199
Ivan Blinkov Avatar answered Nov 17 '25 21:11

Ivan Blinkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!