Postgres Practice
Hands-on lessons on the features real Postgres has beyond standard SQL - JSONB, arrays, RETURNING, upsert, CTEs, window functions, and recursive queries - against a real Postgres running in your browser.
Postgres Practice
Twelve short, hands-on lessons on what Postgres adds on top of standard SQL.
The first seven cover the everyday extras: a JSONB column for
document-shaped data, arrays as a real column type, RETURNING to get a row
back from an INSERT, UUID primary keys generated with
gen_random_uuid(), and ON CONFLICT DO UPDATE for upserts. Lessons 8-12
go deeper into the analytical toolkit: CTEs with WITH (single, chained,
and recursive) and window functions (RANK with PARTITION BY, LAG for
month-over-month change). If you've done the SQL Practice module, this picks
up where it leaves off - same Run-and-check format, but against a genuine
Postgres instance (compiled to WebAssembly, running entirely in your
browser - no server, no setup).
Start with lesson 1. You can leave and come back any time - your code is saved locally.
Lessons
12 total- 01 JSONB: read fields out of a JSON column
- 02 JSONB: filter rows with @>
- 03 Arrays: a column that holds a list
- 04 RETURNING: get the row back from an INSERT
- 05 UUID primary keys with gen_random_uuid()
- 06 Upsert: ON CONFLICT DO UPDATE
- 07 Fix the bug: Postgres's strict GROUP BY
- 08 CTEs: naming a step with WITH
- 09 Chaining CTEs
- 10 Window functions: RANK with PARTITION BY
- 11 LAG: comparing to the previous row
- 12 Recursive CTEs (capstone)