> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lancedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ALTER COLUMN

> Change an existing column's data type or nullability.

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

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
ALTER TABLE <table> ALTER COLUMN <column> SET DATA TYPE <type>;
ALTER TABLE <table> ALTER COLUMN <column> DROP NOT NULL;
ALTER TABLE <table> ALTER COLUMN <column> SET NOT NULL;
```

| Operation | Effect |
| - | - |
| `SET DATA TYPE <type>` | Converts existing values to a supported target type. |
| `DROP NOT NULL` | Allows the column to contain `NULL` values. |
| `SET NOT NULL` | Validates existing data and prevents future `NULL` values. |

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](https://docs.lancedb.com/enterprise/v1-16-0/sql/identifiers.md) 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:

```sql theme={"theme":{"light":"vitesse-light","dark":"catppuccin-mocha"}}
ALTER TABLE items ALTER COLUMN quantity SET DATA TYPE BIGINT;
ALTER TABLE items ALTER COLUMN quantity DROP NOT NULL;
ALTER TABLE items ALTER COLUMN quantity SET NOT NULL;
```

## 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.