sql · level 1 · unit 6 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
adds a new row to a table.
So far you have only asked questions. Now you can change the data. Each complete instruction is a , and a query is one kind. INSERT is another: it adds a new row.
Write INSERT INTO, the table name, then and the new values in brackets. Give one value for every column, in the same order as the table: name, species, age.
An INSERT shows nothing, so add a SELECT underneath to check that your new row is there.
INSERT INTO pets VALUES ('Mabel', 'hen', 2);
SELECT * FROM pets WHERE species = 'hen'; Each time you press run the database starts fresh, so your changes never pile up.
guess first
A new pet joins. How many are there now?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
INSERT INTO pets VALUES ('Mabel', 'hen', 2);
SELECT COUNT(*) AS pets FROM pets;
your turn
Your turn. Add your own pet.
Fill in a name, a species and an age for a new pet. The name and species are text, so they keep their quotes. The age is a number, so it has none.
result
Your answer appears here as a table.
fix it
This new pet is missing something. Fix it!
result
Your answer appears here as a table.
- Read the error. How many columns does the table have, and how many values did you give?
- The pets table has name, species and age. Mabel's age is missing.
- Add a comma and 2 after 'hen', then press run.
nailed it
you added a brand new row. :D
INSERT INTO table VALUES (...)adds a new row.- Give one value per column, in the table's order.
- Add a
SELECTafterwards to check it worked.
new words in your collection
- statement
- INSERT
- VALUES
This lesson isn’t saved. A free account remembers every lesson you finish.