← SQL and databases

Adding rows with INSERT

Put new data into a table.

Start this lesson

INSERT INTO table (columns) VALUES (values); adds a row. The values go in the same order as the column list. Text goes in quotes, numbers do not, and NULL means "no value". You can add several rows at once by writing several value groups separated by commas.

INSERT INTO members (id, name, city, joined, email)
VALUES (9, 'Iris Novak', 'Lakeside', '2024-11-02', NULL);

Adds a ninth member who has not given an email yet.

You can skip the column list and give a value for every column in table order, but naming the columns is safer: it still works if the table changes, and readers can see what each value means.

Leave out the id column and SQLite picks the next id for you.