Home / SQL / Reference / Tables and design

SQL ALTER TABLE

Change an existing table.

Syntax

ALTER TABLE t ADD COLUMN col TYPE;
ALTER TABLE t RENAME COLUMN a TO b;
ALTER TABLE t RENAME TO new_name;

SQLite supports adding, renaming and dropping columns; other databases also allow changing a column's type.

Example

Query (on the shop database used in the SQL course)

ALTER TABLE products ADD COLUMN on_sale INTEGER DEFAULT 0;
SELECT name, on_sale FROM products LIMIT 3;

Result

nameon_sale
Wireless mouse0
Mechanical keyboard0
USB-C hub0

3 rows

Related

Learn it step by step in the free lesson Creating Tables, with exercises that check your queries.