Write SQL and run it on a real SQLite database right in your browser. Start from a sample company, store or school database, run several statements at once, then export results as CSV or download the whole database.
Last updated:
1
Ln 1, Col 1Ctrl + Enter runs all · select text to run only that part
Loading the SQLite engine…
Advertisement
Advertisement
How to use the SQL Online Compiler
Pick a database: a sample company, online store or school, or an empty one. Its tables and columns appear on the left.
Write SQL in the editor, or click an example query above it.
Press Run SQL or Ctrl + Enter. To run just part of the script, select it first.
Read the results. Each statement shows its rows, the rows it changed and how long it took. Errors mark the line.
Export a result as CSV, or press Download .db to keep the database with your changes.
SQL quick reference (SQLite)
Task
SQL
Filter and sort
SELECT name, salary FROM employees WHERE salary > 100000 ORDER BY salary DESC LIMIT 5;
Join two tables
SELECT e.first_name, d.name FROM employees e JOIN departments d ON d.id = e.department_id;
Keep rows without a match
… FROM departments d LEFT JOIN employees e ON e.department_id = d.id
Aggregate per group
SELECT department_id, COUNT(*), AVG(salary) FROM employees GROUP BY department_id HAVING COUNT(*) > 2;
Rank within groups
RANK() OVER (PARTITION BY department_id ORDER BY salary DESC)
Named subquery (CTE)
WITH big AS (SELECT * FROM orders WHERE total > 100) SELECT COUNT(*) FROM big;
Conditional value
CASE WHEN score >= 90 THEN 'A' WHEN score >= 80 THEN 'B' ELSE 'C' END
INSERT INTO t (id, n) VALUES (1, 'a') ON CONFLICT(id) DO UPDATE SET n = excluded.n;
Change and remove rows
UPDATE products SET stock = stock - 1 WHERE id = 3;DELETE FROM orders WHERE status = 'cancelled';
The sample databases
Company: departments, employees (with a manager_id that points back to employees, ideal for self joins), projects and the link table employee_projects. One intern has no department, so you can see how INNER and LEFT joins differ.
Online store: customers, products, orders with a status CHECK constraint, and order_items. Good for revenue totals, monthly reports and finding customers without orders.
School: students, courses and enrollments with scores, one of them still NULL. Practise averages, CASE grading, ranking and NOT EXISTS.
All data is fictional. Edit it freely: Reset data restores the original rows at any time.
SQLite in a nutshell
SQLite stores a whole database in a single file and is the most widely deployed database engine: it ships inside every major browser, phone operating system and countless desktop apps. Columns have a type affinity rather than a strict type, so a TEXT column can still hold a number unless you declare the table STRICT. A column declared INTEGER PRIMARY KEY becomes the row id and fills itself in automatically when you insert NULL or leave it out. Booleans are stored as 0 and 1, which is why SUM(status = 'cancelled') counts matching rows.
Frequently asked questions
Which SQL dialect does this compiler use?
SQLite 3, through sql.js, the official SQLite C code compiled to WebAssembly. It supports standard SELECT, joins, GROUP BY, subqueries, CTEs (WITH and WITH RECURSIVE), window functions such as RANK and ROW_NUMBER, UPSERT, JSON functions and date functions. Server features such as stored procedures, users and GRANT do not exist in SQLite.
Is my data saved?
The database lives in your browser's memory while the page is open. Reloading or switching databases resets it to the sample data, but your SQL text is remembered on this device. Press Download .db to keep a copy with all your changes, and open it again later with Open .db.
Can I practise MySQL or PostgreSQL queries here?
Most everyday SQL works the same: SELECT, WHERE, JOIN, GROUP BY, ORDER BY, LIMIT, INSERT, UPDATE and DELETE. Differences show up in data types, string functions and dates: SQLite uses || to join strings, strftime() and date() for dates, and has no ILIKE or SERIAL. Use INTEGER PRIMARY KEY for auto-increment ids.
How do I run several statements?
Separate them with semicolons and press Run. They run in order, and each statement that returns rows gets its own result table. If one fails, the statements before it have already run and the error shows where it stopped.
Are my queries or files uploaded?
No. SQLite runs entirely inside your browser tab. Your SQL, the sample data and any .db file you open never leave your device.
How large can a database be?
Databases are held in memory, so files of tens of megabytes work well on most computers. Very large files may be slow to open or exceed the memory available to the browser tab. The result grid shows the first 1,000 rows, while CSV export includes every row.
Why do I get 'no such column' when the column exists?
Usually because a string was written in double quotes. In SQL, 'single quotes' mark text values and "double quotes" mark names, so WHERE name = "Ann" looks for a column called Ann. Write WHERE name = 'Ann' instead.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.