Modify an existing table’s structure.

Modifies a column definition: changing type, setting/dropping defaults, altering nullability. Can be fast (metadata-only) or require a full table rewrite depending on the change. Test on a production-size clone before running against live data.

Compatibility

Show:
Database System Support Status Since Version Notes
MySQL ✓ Supported all Multiple ALTER per stmt
PostgreSQL ✓ Supported all Standard
SQL Server ✓ Supported all Standard
Oracle ✓ Supported all Standard
SQLite ✓ Supported all Limited: only ADD

Details

DDL for evolving schemas.

Standard Syntax

ALTER TABLE table_name ADD COLUMN new_col VARCHAR(50);

Version Support

MySQL: Since all PostgreSQL: Since all SQL Server: Since all Oracle: Since all SQLite: Since all

Per-Database Syntax & Notes

MySQL

Multiple ALTER per stmt

ALTER TABLE tbl ADD COLUMN nick VARCHAR(50), DROP COLUMN old_col;

PostgreSQL

Standard

ALTER TABLE tbl ADD COLUMN nick TEXT; ALTER TABLE tbl DROP COLUMN old_col;

SQL Server

Standard

ALTER TABLE tbl ADD nick NVARCHAR(50); ALTER TABLE tbl DROP COLUMN old_col;

Oracle

Standard

ALTER TABLE tbl ADD nick VARCHAR2(50); ALTER TABLE tbl DROP COLUMN old_col;

SQLite

Limited: only ADD

ALTER TABLE tbl ADD COLUMN nick TEXT;