Write each query here, and run it on a real Postgres database in your browser.
Add new videos to the videos table, and get back what Postgres filled in for them.
Scenario
Simplified's team is publishing the videos of its next chapters. You write the INSERT its server sends for each of them.
Simplified's videos table holds eight videos so far, in chapters 1 to 3.
Can you add the next ones, the way Simplified's server does?
These queries change the table. After each run, you'll see videos as your query left it.
The team adds a video called Ties, to chapter 3. It hasn't been recorded yet.
Add its row to videos.
Give only its title and chapter. Postgres fills in the rest.
Your INSERT never named id or seconds, so Postgres filled them in.
Send back the id, title and seconds of the row whose title is Ties.
Chapter 4 opens with three recorded videos: Several rows at once, The missing WHERE and What a write reports.
They run for 90, 105 and 85 seconds.
Add all three rows with one INSERT, in that order.
One more video joins chapter 4: The foreign key, not recorded yet.
Simplified's server needs the new row's id at once, to link to it.
Predict that id. Then add its row, and have the same query send its id back.
The next one is called One-to-many. It's in chapter 4, and runs for 130 seconds.
An assistant wrote this INSERT for it. Postgres runs it without an error.
Run it, look at videos after it, then fix it.
null value in column "title" of relation "videos" violates not-null constraint
The INSERT gave no title, and title is NOT NULL.
Name title in the brackets after videos, and give its value.
cannot insert a non-DEFAULT value into column "id"
Leave id out of the INSERT. Postgres generates it.
INSERT has more expressions than target columns
VALUES gives more values than the columns you named.
Give one value for each column, in the same order.
invalid input syntax for type integer: "Several rows at once"
A title landed in a number column, so the values are out of order.
Give them in the order the columns are named.
Each step passes once its query sends back the right rows, or makes the right change. Then mark the lab complete to unlock the next lesson.