SQLite Playground
Practice SQL on real sample data, right in your browser. Pick a dataset, try a ready-made command, or write your own query.
Loading SQLite engineβ¦
Tables & relationships
Each box is a table. Lines show how tables connect β π marks the primary key (a row's unique ID), π marks a foreign key (a column that points to another table).
Try a command
SQL editor
Recent queries
SQL in plain English
A short, jargon-free reference β from the basics to the more advanced stuff. Open any topic below.
What is SQL, really?
SQL is just a way of asking questions about data stored in tables β the same way a spreadsheet stores data in rows and columns. You write a sentence-like instruction ("give me all customers from Milan") and the database hands back the matching rows.
Tables, rows and columns
A table is like one spreadsheet tab: it has columns (the kind of information, like "name" or "price") and rows (one entry per item β one row per customer, one row per order). A database is just a collection of these tables.
SELECT, WHERE, ORDER BY
SELECT picks which columns you want to see.
WHERE filters rows down to the ones matching a condition,
like a search box. ORDER BY sorts the results. Think of it
as: "show me these columns, only for these rows, in this order."
JOIN β combining tables
Real data is usually split across several tables to avoid repeating
information. A JOIN temporarily glues two tables together
using a shared value β for example, matching each order to its
customer's name. It doesn't change your tables, it just shows them
side by side for that one query.
Junction tables (many-to-many)
Sometimes two things can each relate to many of the other β a student takes many courses, and a course has many students. A single link column can't capture that, so a small "in-between" table is used to record each pairing (one row per student-course combination). Joining through that middle table connects the two sides.
GROUP BY and aggregate functions
Aggregate functions summarize many rows into one number:
COUNT (how many), SUM (total),
AVG (average), MIN/MAX
(smallest/largest). GROUP BY runs that summary separately
for each group β like "total sales, per city" instead of one grand
total.
Subqueries
A subquery is a query nested inside another query. The inner query runs first and produces a small list of values (like a list of IDs); the outer query then uses that list to filter its own results. It's a way of saying "find X, based on something I need to look up first."
Views
A view is a query you save under a name, so it behaves like a
ready-made table you can query again later without retyping the
JOIN or filtering logic. It doesn't store a copy of the
data β it just re-runs the saved query each time you use it.
Indexes
An index is like the index at the back of a book: instead of scanning every page (row) to find something, the database can jump straight to it. It speeds up searching and sorting on a column, at the small cost of extra storage.
Window functions (advanced, but simple in spirit)
Normally, an aggregate like SUM collapses many rows into
one. A window function does a similar calculation β like a running
total, a rank, or "compare this row to the one before it" β but keeps
every row visible. It's the SQL version of a spreadsheet formula that
can peek at other rows without merging them together.
Changing structure vs. changing data
Commands like CREATE TABLE, ALTER TABLE and
DROP TABLE change the shape of your database β adding or
removing tables and columns. Commands like INSERT,
UPDATE and DELETE change the data inside
that shape, without touching its structure.