SQLite Playground
Run SQLite queries on a small database in your browser, open or download a database file, browse tables and keep several SQL scripts.
Press Run to see the result tables here. The sample tables are listed on the right.
Shortcuts: Ctrl+Enter run · / search (use ⌘ on Mac)
Free Online SQLite Playground
Run SQL on a small database. A sample company database is ready (employees, departments and orders, about 200 rows), so you can try a query in seconds, or start empty and build your own tables. You can also open a SQLite file from your computer and download your database again. It all happens in your browser. It uses the real SQLite engine, so queries behave the way they do in your own projects.
How to use the playground
- Type SQL in the editor. End each statement with a semicolon. The tabs above the editor are separate script files.
- Press Run (or Ctrl+Enter) to run the open file. Select some text first to run only that part. Run all runs every file, from the first tab to the last.
- Read the results on the right: one table for each statement, with the number of rows and the time. A statement that changes data tells you how many rows it changed.
- Click a table name in the Schema list to add
SELECT * FROM table LIMIT 100;to your file. - Use Explain to see how SQLite plans the last statement, and the ⋯ menu to download the database, open a file, reset or change the time limit.
What happens when something goes wrong
A mistake shows the statement number, the line and what SQLite said, with a short tip. Statements before the mistake keep their effect and the ones after it do not run. If you need to format a long query first, try the SQL Formatter, or turn a JSON list into INSERT statements with JSON to SQL.
Worked example
With the sample database loaded, this query counts the people in each department and their average pay:
SELECT d.name AS department, COUNT(*) AS people, ROUND(AVG(e.salary)) AS average_salary FROM employees e JOIN departments d ON d.id = e.department_id GROUP BY d.name ORDER BY average_salary DESC;
The result has six rows. The first three are:
department | people | average_salary -----------+--------+--------------- Finance | 6 | 65733 Support | 7 | 63711 Marketing | 7 | 62341
Common mistakes
- Forgetting the semicolon between two statements. SQLite then reads them as one and reports a mistake near the second word.
- Using double quotes for text. In SQL, text goes in single quotes:
'Sales'. Double quotes are for names of tables and columns. - Writing
= NULLto find empty values. UseIS NULL. - Expecting changes to stay after you close the tab. Download the database or press Save for your scripts.