← SQL tutorial

SQL

INSERT INTO

INSERT INTO table (columns) VALUES (values) adds a new row.

Example: adding a new student

INSERT INTO students (name, track, score)
VALUES ('Ngozi', 'Frontend', 88);
1 row inserted.

The columns listed and the values listed must match up in the exact same order, here, 'Ngozi' goes to name, 'Frontend' to track, 88 to score. Notice id wasn't included at all, most real tables auto-generate a new id for each inserted row, so you almost never specify it yourself.

Example
INSERT INTO students (name, track, score)
VALUES ('Ngozi', 'Frontend', 88);
Output
1 row inserted.
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Backend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account