Home > Net >  Clickhouse - add a new column with the default value being based off another column
Clickhouse - add a new column with the default value being based off another column

Time:09-16

I have a table in Clickhouse, table1, with columns A and B. I want to alter this table to have a new column C. For the purpose of default values (future data will have a different approach) I want C to be filled in with data from A.

I know how to achieve this with a static default value, e.g. 0 but that is not what I'm trying to achieve here.

CodePudding user response:

DEFAULT may accept expression not only static value:

ALTER TABLE table1 ADD COLUMN C String DEFAULT A
  • Related