Playgrounds / PostgreSQL
SQL sandbox
Try a query. Change it. See what the database does.
New to SQL? Start here
From product IDs to an order
Read a shop’s records, join a product name to a purchase and calculate its total.
4 guided steps · Editable SQL
Have a query in mind?
Explore a small shop database with five tables, or write SQL of your own.
Nothing to install. SQL runs in this browser tab. Leaving or restarting discards your practice data.
SQL editor
Ctrl / ⌘ + EnterRun sends everything in the editor. You can change the SQL and run it again.
Enable JavaScript to start the database.
Result
Run the SQL above to see its result here.
Compare with the lesson
You changed the example. Compare your query with the lesson before drawing the same conclusion.
Lesson complete
You’ve run every step. Try a variation in the editor, revisit the article, or choose another lesson.
Previous runs
Database help & session controls
Your session
One connection stays open between runs. Without explicit transaction commands, PostgreSQL treats everything in one run as one transaction: an error rolls back earlier changes in that batch. Send separate runs to inspect an answer before continuing.
Restart restores the original shop, clears results and returns a lesson to step one. Leaving or reloading this page also discards the database.
Loading a query changes the editor; it does not run it.
Reading a response
SELECT 2 means two rows were returned. UPDATE 1 means one row matched the update. In INSERT 0 1, the final 1 counts inserted rows. Changes in an open transaction still need COMMIT.
A failed transaction needs ROLLBACK before another statement can succeed. An error may be the point of a lesson; compare its explanation with the database response.
About this playground
This is PostgreSQL running locally through PGlite, with one connection and disposable data. It supports SQL, not psql’s backslash commands. It does not reproduce separate concurrent connections, network failures or server performance.
Large results show at most 200 rows and 40 columns per statement, 2,000 characters per cell, 5,000 cells, 250,000 cell characters and 50 responses per run. The editor accepts up to 100,000 characters. The five most recent runs are kept. A run lasting 20 seconds automatically discards its session; you can stop it sooner.