ALTER TABLE ... MODIFY COLUMN lets you change a column’s data type in ClickHouse while preserving data.
Run ALTER TABLE table_name MODIFY COLUMN col_name new_type. ClickHouse rewrites data in the background, so the table stays queryable.
Syntax appears below. You can also reposition the column with AFTER and change default or codec settings in one statement.
Yes. ClickHouse performs the mutation asynchronously.Monitor system.mutations to track progress and avoid heavy loads during peak traffic.
Use FINAL only when immediately querying the table after the mutation and you require fully merged data. Otherwise, let background merges finish naturally.
Select * from system.mutations where table = 'Orders' to see status, progress, and possible failures.
Suppose you stored price as Float32 but need better precision.ALTER TABLE Products MODIFY COLUMN price Decimal(18,2) updates the type without dropping data.
1) Schedule large mutations during low-traffic windows. 2) Always test on a staging replica. 3) Backup data or verify replication health before execution.
.
No. ClickHouse keeps the table readable and writable. Only affected parts are rewritten in the background.
Yes. Use KILL MUTATION WHERE mutation_id = 'xxx' to stop it, but partial changes remain and may need clean-up.
ClickHouse creates new parts with the new format and removes old ones after a successful mutation, ensuring atomic switch-over.