ProductDocumentationExamplesBlogRoadmapGitHubGet Started
Available

ALTER TABLE

Add, drop, rename, and reorder columns; widen types; manage schema evolution.

ALTER TABLE in Krishiv is supported primarily for Iceberg tables. The operations are metadata-only for the most part — no data rewrite required.

Supported operations

OperationSQL formWhat it does
Add columnALTER TABLE t ADD COLUMN c TYPEMetadata-only. New column is NULL for existing rows.
Drop columnALTER TABLE t DROP COLUMN cMetadata-only. Readers return NULL.
Rename columnALTER TABLE t RENAME COLUMN old TO newMetadata-only. Existing queries break.
Reorder columnALTER TABLE t ALTER COLUMN c AFTER otherMetadata-only. Storage layout unchanged.
Widen typeALTER TABLE t ALTER COLUMN c TYPE NEWMetadata-only if the new type is a superset (e.g. INT → BIGINT, FLOAT → DOUBLE).
Set commentALTER TABLE t ALTER COLUMN c COMMENT '...'Metadata-only.
Add partition specALTER TABLE t ADD PARTITION FIELD bucket(16, id)Metadata-only. New writes use the new spec; old data is not rewritten.

Examples

-- Add a new column (NULL for existing rows)
ALTER TABLE orders ADD COLUMN region VARCHAR;

-- Rename safely (will break old queries — deploy in lockstep)
ALTER TABLE orders RENAME COLUMN amt TO amount;

-- Widen a type (INT → BIGINT is metadata-only)
ALTER TABLE orders ALTER COLUMN user_id TYPE BIGINT;

-- Drop a column
ALTER TABLE orders DROP COLUMN legacy_col;

Compatibility modes

Set the compatibility mode on the table to control which operations are allowed:

ModeDescription
backward (default)Old readers can read new data. Add/drop/widen are OK.
forwardNew readers can read old data. Drop/widen are OK.
fullBoth. Most restrictive.
noneNo checks. Use only for development.

Branches and tags for risky changes

For destructive experiments, branch first:

-- Create a branch at the current main snapshot
CALL system.create_branch('orders', 'experiment', main_ref);

-- Run the migration on the branch
ALTER TABLE orders_branch ADD COLUMN region VARCHAR;

-- Inspect via time-travel
SELECT * FROM orders FOR SYSTEM_TIME AS OF 'experiment';

-- Promote or drop
CALL system.fast_forward('orders', 'experiment', main_ref);
CALL system.drop_branch('orders', 'experiment');

Unsupported operations

  • Narrowing a column type (DOUBLE → FLOAT).
  • Renaming a partition column.
  • Changing the partition spec on existing data without a re-partition job.

See also