Schema migrations, ALTER patterns, engine changes, data backfill, and zero-downtime migration strategies.
Load when users ask about schema changes, migrations, or engine upgrades.
ALTER TABLE t ADD COLUMN col Type [DEFAULT expr] [AFTER existing_col]ALTER TABLE t DROP COLUMN colALTER TABLE t MODIFY COLUMN col NewType (must be compatible)ALTER TABLE t RENAME COLUMN old TO newCREATE TABLE t_new ENGINE = ReplacingMergeTree() ORDER BY id AS SELECT * FROM t_old;
RENAME TABLE t_old TO t_backup, t_new TO t_old;
INSERT INTO ... SELECT with batchingCREATE MATERIALIZED VIEW mv TO t_new AS SELECT ... FROM t_oldINSERT INTO t_new SELECT ... FROM t_oldINSERT INTO new SELECT * FROM old WHERE toYYYYMM(date) = 202301max_insert_block_size and max_threads for throughput controlsystem.processes and system.mergesALTER TABLE t ATTACH PARTITION id FROM other_table — zero-copy if same structureALTER TABLE t REPLACE PARTITION id FROM other_table — atomic swapALTER TABLE t MOVE PARTITION id TO TABLE other_table — move data