Skip to content

SQL INSERT INTO

INSERT INTO adds new rows to a table. You name the table and the columns you are filling, then give a value for each of those columns, in the same order.

INSERT INTO table_name (column1, column2, column3)
VALUES (value1, value2, value3);

The examples add to the Productions and Invoices tables from the example database.

To add a new feature film:

INSERT INTO Productions (ProductionID, Title, Format, Country, Budget)
VALUES (6, 'Ember Street', 'Feature film', 'UK', 5400000);

The table gains one row:

ProductionID Title Format Country Budget
6 Ember Street Feature film UK 5,400,000

You can leave out the list of columns when you give a value for every column, in the order the table defines them. It is shorter, but it breaks as soon as someone adds or reorders a column, so naming the columns is the safer habit.

Columns you leave out are filled with their default value, which is NULL unless the table sets another one. Here only the title and format are known so far:

INSERT INTO Productions (Title, Format)
VALUES ('North Light', 'Documentary');
ProductionID Title Format Country Budget
7 North Light Documentary

ProductionID filled itself in with the next number because the table numbers its rows automatically; SQL Auto Increment explains how. Country and Budget are left empty, which is NULL.

Most databases let one statement add several rows, with a bracketed list of values for each:

INSERT INTO Invoices (InvoiceID, ProductionID, Supplier, Amount, InvoiceDate)
VALUES
(1005, 3, 'Hartwell Lighting', 8750.00, '2025-05-21'),
(1006, 3, 'Kestrel Catering', 1460.00, '2025-05-22');
InvoiceID ProductionID Supplier Amount InvoiceDate PaidDate
1005 3 Hartwell Lighting 8,750.00 2025-05-21
1006 3 Kestrel Catering 1,460.00 2025-05-22

To copy rows from another table rather than typing them, see SQL Insert Into Select.