sql · level 1 · unit 7 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
builds a new, empty table.
Until now, every table was ready and waiting. CREATE TABLE builds your own. Give it a name, then list its columns in brackets, with commas between.
Each column gets a name and a : the kind of value it holds. TEXT is for words. INTEGER is for whole numbers, like ages and scores.
A new table starts empty, so INSERT some rows before you SELECT. Make a table with a name that is already taken and you get table already exists.
CREATE TABLE plants (name TEXT, height INTEGER);
INSERT INTO plants VALUES ('Fern', 40), ('Cactus', 12);
SELECT * FROM plants; Table and column names follow the alias rules: one word, or words joined with underscores.
guess first
A brand new table. What will this show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
CREATE TABLE friends (name TEXT, age INTEGER);
SELECT * FROM friends;
your turn
Your turn. Design your own table.
Pick a name for a table about something you collect, like stickers or mugs, and type it in the three table-name blanks. Then fill in one row: a name and how many you have.
result
Your answer appears here as a table.
fix it
The farm sounds table will not build. Fix it!
result
Your answer appears here as a table.
- Read the error. What does it say about the name pets?
- This database already has a pets table, so your new table needs a name of its own, like sounds.
- Change pets to sounds on all three lines, then press run.
nailed it
you built a table of your own. :D
CREATE TABLE name (column TYPE, ...)builds a new table.TEXTholds words.INTEGERholds whole numbers.- A new table starts empty, and
INSERTfills it.
new words in your collection
- CREATE TABLE
- data type
This lesson isn’t saved. A free account remembers every lesson you finish.