← 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.