Skip to main content
Enterprise only
Use ALTER TABLE ... ALTER COLUMN to change one existing column in LanceDB Enterprise. These statements require table ownership and use the same validation as the REST alter_columns API.

Syntax

Specify one column and one operation per statement. To change both type and nullability, change the type first. Each statement commits independently; a later failure does not roll back an earlier statement. The TYPE <type> alias and USING <expression> clause are not supported. These forms take a top-level column name. Follow the identifier quoting rules for names containing spaces or dots; a quoted name such as "a.b" identifies one column, not a nested field.

Example

For an integer quantity column on items with no null values:

Restrictions

  • Type names use the same SQL mapping as CREATE TABLE. Type changes accept only casts supported by REST alter_columns; a cast supported in a SELECT expression may still be rejected for schema evolution.
  • Drop indexes that depend on the column before changing its type, then recreate them after the change.
  • SET NOT NULL rejects existing NULL values. Deleted rows or earlier values hidden by updates can retain nulls even when live rows contain none; the error explains the required compaction.
  • Tables with real-time streaming enabled cannot change column types or tighten a nullable column to NOT NULL. DROP NOT NULL remains available.
  • Computed columns cannot be retyped. Columns read or written by a Function binding cannot have their type or nullability changed through these forms.
  • Members of a multi-output virtual column group cannot be altered. Drop and redeclare the whole group to change its schema.
A rejected statement leaves the table’s schema and data unchanged.