Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating data in Clickhouse

I went over the documentation for Clickhouse and I did not see the option to UPDATE nor DELETE. It seems to me its an append only system. Is there a possibility to update existing records or is there some workaround like truncating a partition that has records in it that have changed and then re-insering the entire data for that partition?

like image 585
Jonathan Avatar asked Jun 18 '16 21:06

Jonathan


People also ask

What is database Updation?

The modification of data that is already in the database is referred to as updating. You can update individual rows, all the rows in a table, or a subset of all rows. Each column can be updated separately; the other columns are not affected.

What is mutation in ClickHouse?

The table contains information about mutations of MergeTree tables and their progress. Each mutation command is represented by a single row. Columns: database (String) — The name of the database to which the mutation was applied.


2 Answers

Through Alter query in clickhouse we can able to delete/update the rows in a table.

For delete: Query should be constructed as

ALTER TABLE testing.Employee DELETE  WHERE  Emp_Name='user4';

For Update: Query should be constructed as

ALTER TABLE testing.employee UPDATE AssignedUser='sunil' where AssignedUser='sunny';
like image 185
Sunil Sunny Avatar answered Sep 19 '22 19:09

Sunil Sunny


It's an old question, but updates are now supported in Clickhouse. Note it's not recommended to do many small changes for performance reasons. But it is possible.

Syntax:

ALTER TABLE [db.]table UPDATE column1 = expr1 [, ...] WHERE filter_expr

Clickhouse UPDATE documentation

like image 44
supernova Avatar answered Sep 20 '22 19:09

supernova