Skip to content

Add a column to an existing table ​

Use ALTER TABLE ... ADD COLUMN with a definition that works for existing rows as well as future inserts. A required field commonly needs a suitable default so the current dataset remains valid.

sql
ALTER TABLE profiles ADD COLUMN status String NOT NULL DEFAULT 'new';

Review the application contract ​

Decide what the default means for old rows. A convenient placeholder can become misleading business data if it is never backfilled. If the field is unknown for old records, a nullable declaration may express the intended meaning more accurately.

Update explicit import and export column lists deliberately. Existing inserts that name their columns can continue omitting the new field according to its default behavior. Code that assumes every table column or a fixed positional layout needs review.

Verify the result ​

Inspect system.columns for the new type, position and default expression, then query a few existing rows and insert a representative new row. Include null and boundary cases when the column has constraints.

Adding a column does not change another column's type. For a type conversion, create a replacement table and use INSERT ... SELECT CAST(...), then validate before changing the application reference. Check dependencies before any later drop or rename.

See ALTER TABLE columns, CREATE TABLE and system.columns.