SQL Sandbox

A real SQL database running in your browser. Type any SQL, press Run, see the result. Nothing you do here can break anything.

How it works: pick a starting point below. Empty database gives you a blank database to build your own tables from scratch. Shop database loads the online art shop from A3.3 Database Programming. Your tables, data and SQL are saved in your browser, so they are still there when you come back. Run several statements at once by ending each with ;. Shortcut: Ctrl+Enter.

Tables

Your database right now. Click a table name to see all its rows. Underlined = primary key, red italic = foreign key.

Loading database...

Editor

Loading SQL engine...

Results appear here.

Examples to try

These use the shop tables, so switch to Shop database first. Click one to load and run it.

Challenges

Use the shop database. Write these yourself. Answers are in the A3.3 practice exercises.

  1. List every customer in France, sorted by city.
  2. Show every item that costs less than 30, with the name of the artist who made it.
  3. Count how many customers there are in each country.
  4. Find the total quantity sold of each item.
  5. Find the items that have never been bought.
  6. Add yourself as a customer, then record a purchase for yourself.
  7. Create a table Review with a review ID, an item ID (foreign key) and a star rating, then insert two reviews.
Ninja Notes: