How to Rename a Column in ClickHouse
To rename a column in ClickHouse, use the ALTER TABLE
statement in combination with RENAME COLUMN
.
This example renames the column my_column
to my_renamed_column
:
ALTER TABLE my_table RENAME COLUMN my_column TO my_renamed_column;
Include the IF EXISTS
clause if you don’t want the query to return an error in case my_colum
doesn’t exist:
ALTER TABLE my_table RENAME COLUMN IF EXISTS my_column TO my_renamed_column;