SQL Playground
Create tables, insert rows and query them. A real SQLite database living in your browser tab, with the schema and results shown as you go.
← VizLearnTables
Try
CREATE TABLEyour own, then insert into it — it stays until you reload.- A
LEFT JOINfrom artists: Nina Simone has a NULL country, so you can see how NULL behaves. SELECT * FROM albums ORDER BY sales DESC LIMIT 3- A window function —
RANK() OVER (ORDER BY sales DESC).
How it works
This is SQLite compiled to WebAssembly. The database lives in memory in this tab — nothing is uploaded, and a reload starts clean.
Ctrl/Cmd + Enter runs.
Which SQL this is
SQLite, compiled to WebAssembly and running in your browser. The
database lives in memory: it is created when the page loads, it keeps
your changes while you work, and Reset database puts the
sample tables back exactly as they were.
SQLite is the most widely deployed database in the world and its
dialect is close to standard SQL, so almost everything you write here
transfers to PostgreSQL or MySQL. The differences worth knowing are
small: SQLite is relaxed about types, storing whatever you give a
column; it has no dedicated date type, using text or numbers instead;
and || concatenates strings where MySQL would use
CONCAT.
What is supported
SELECTwithWHERE,GROUP BY,HAVING,ORDER BYandLIMIT.- All the joins — inner, left, cross, and self-joins.
- Common table expressions, including recursive ones, and window
functions such as
ROW_NUMBER,RANKandSUM() OVER (). INSERT,UPDATE,DELETE,CREATE TABLEandCREATE INDEX, so you can build your own schema and query it.- Transactions, and
EXPLAIN QUERY PLANfor seeing how a query will be executed.
Errors you will see
no such column usually means a typo, or a column named in
SELECT that is neither grouped nor aggregated.
no such table means the name is wrong or the table was dropped
— reset to bring the samples back.
ambiguous column name means two joined tables share a column
name, so it needs qualifying as table.column.
An empty result is not an error. It usually means the
WHERE clause matched nothing, and the quickest way to find
out is to remove conditions one at a time until rows appear.
Things worth trying
- Group by two columns and watch the row count change, then add a column that is neither grouped nor aggregated and see what SQLite does with it.
- Write the same question as a join, as a subquery, and as a CTE, and compare which one you would rather read in six months.
- Put
EXPLAIN QUERY PLANin front of a query, add an index, and run it again to see the plan change. - Create your own table, insert a few rows, and break a constraint deliberately.
Learning SQL?
The Databases & SQL track works through the clauses in the order the engine actually applies them — which explains most of the errors people hit. Start with query execution order.