SQL from Zero › Module 3: DML: filling and changing data

Adding rows with INSERT

Stock the shelves: add new authors, books and customers.

Lesson 13 of 33 · about 12 minutes

Video: Stocking the shelvesThe narrated video for this lesson is coming soon. The lesson below covers the same ideas.

The lesson

The shelves are up. Now it's time to stock them. From here on your practice database is the full bookshop, already filled with authors, books, customers and orders. You'll add to it with DML, starting with INSERT.

INSERT INTO authors (id, name, country)
VALUES (11, 'Jane Austen', 'UK');

Reading it out loud: "Into the authors table, for the columns id, name and country, add these values."

  • The values go in the same order as the columns you listed.
  • Text goes in single quotes. Numbers don't.
  • If a value contains an apostrophe, write it twice: 'The Handmaid''s Tale'.

Leave out what fills itself in. The id is an INTEGER PRIMARY KEY, so if you skip it the database picks the next number:

INSERT INTO authors (name, country) VALUES ('Chinua Achebe', 'Nigeria');

Add several rows at once by separating them with commas:

INSERT INTO customers (name, city, country, joined_on) VALUES
  ('Mateo García', 'Madrid', 'Spain', '2025-09-10'),
  ('Lina Haddad', 'Dubai', 'UAE', '2025-09-12');

Run SELECT * FROM authors; afterwards to see your new rows.

Key ideas
  • INSERT INTO table (columns) VALUES (values) adds a row.
  • Values go in the same order as the columns; text goes in single quotes.
  • Leave out columns that fill themselves in, like an INTEGER PRIMARY KEY or a DEFAULT. Separate several rows with commas.

Practise

Loading practice…

Quick check

1. Which INSERT is written correctly?

2. You leave out the id when inserting into a table whose id is INTEGER PRIMARY KEY. What happens?

3. How do you add a title with an apostrophe, like Ender's Game?