ALTER TABLE CHANGE COLUMN

Moves an existing column to a new position in the table schema without rewriting data files.

Category: ddlDeltaForge extension

Syntax

ALTER TABLE <table> CHANGE COLUMN <column> FIRST | AFTER <other_column>

Description

## Overview Repositions an existing column within the table schema. This is a metadata-only operation that updates the column ordering in the Delta log without rewriting or touching any data files. ## Behavior - The column must exist in the current schema. If the column is not found, the command fails. - When FIRST is specified, the column is moved to position 0 in the schema field list. - When AFTER <other_col> is specified, the column is moved to the position immediately following the referenced column. - If the referenced AFTER column does not exist, the command fails. - The operation emits a single metadata-only commit to the Delta log. - Two syntax variants are supported: `CHANGE COLUMN <col> FIRST|AFTER` and `ALTER COLUMN <col> FIRST|AFTER`. Both produce the same result. - After the column is moved, the schema observer is notified so the catalog stays in sync. ## Compatibility This is a DeltaForge extension. Column ordering is stored in the Delta schema metadata, which all Delta readers respect. The physical column order in Parquet files is unchanged; readers map columns by name (when column mapping is enabled) or by ordinal position.

Parameters

NameTypeDescription
tableFully qualified table name or registered table name. The table must be registered in the current session.
column_nameColumn to move.
positionFIRST or column name to place after.

Examples

-- Move a column to the first position
ALTER TABLE warehouse.clinical.patients CHANGE COLUMN mrn FIRST;
-- Move a column after another column
ALTER TABLE warehouse.clinical.patients CHANGE COLUMN first_name AFTER mrn;
-- Alternative syntax using ALTER COLUMN
ALTER TABLE warehouse.sales.orders ALTER COLUMN order_date AFTER order_id;
-- Move a column to the beginning using ALTER COLUMN
ALTER TABLE warehouse.sales.orders ALTER COLUMN order_ref FIRST;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →