How to use SQLite online
- Start from a sample database (Employees or Shop) or an empty one, and look at its tables on the Schema tab.
- Write your SQL and press Run SQL or Ctrl + Enter. Each statement gets its own result table; select part of the code to run only that.
- Your tables stay while the page is open, so you can run
CREATE TABLEonce and query it many times. Reset database brings the sample back. - Import a
.sqldump or a.csvfile, export any result as CSV, or press Share to copy a link with your queries. - Stuck on a query? Generate writes SQL from a description, Explain walks through your query and Fix Code repairs errors.
SQLite or another database?
SQLite runs here in your browser, starts instantly and accepts any value in any column unless you make the table STRICT. If your course or job uses PostgreSQL, the SQL Online Compiler runs the same query on PostgreSQL too, and the MySQL Online Compiler runs it on a real MySQL 8.4 server.
Good to know
- It is real SQLite 3.54 compiled to WebAssembly, running in your browser. Your data never leaves your computer.
- Modern SQLite works: window functions,
WITH RECURSIVE, JSON functions and->>,INSERT ... ON CONFLICT(upsert),RETURNING,STRICTtables, generated columns,RIGHTandFULL OUTER JOIN. - The sqlite3 shell's dot commands are not SQL, so
.tablesand.schemado not work here. UseSELECT name FROM sqlite_master WHERE type = 'table';andSELECT * FROM pragma_table_info('employees');instead, or open the Schema tab. - Math functions such as
pow()andsqrt()and full-text search FTS5 are not in this build; FTS4 is. - A query that runs longer than 20 seconds is stopped, and each result shows its first 1,000 rows.
- Need MySQL or PostgreSQL syntax? Switch Engine, or use the MySQL Online Compiler.
SQLite queries to try
List the tables
SELECT name, sql
FROM sqlite_master
WHERE type = 'table';
Dates with strftime and date modifiers
SELECT name,
hired_on,
strftime('%Y', hired_on) AS hire_year,
date(hired_on, '+1 year') AS first_anniversary,
CAST(julianday('2026-01-01') - julianday(hired_on) AS INTEGER) AS days_employed
FROM employees
ORDER BY hired_on;
Upsert with ON CONFLICT
CREATE TABLE stock (product TEXT PRIMARY KEY, qty INTEGER);
INSERT INTO stock VALUES ('Keyboard', 5);
INSERT INTO stock VALUES ('Keyboard', 3)
ON CONFLICT(product) DO UPDATE SET qty = qty + excluded.qty;
SELECT * FROM stock;
JSON in a TEXT column
CREATE TABLE events (id INTEGER PRIMARY KEY, data TEXT);
INSERT INTO events (data) VALUES
('{"user": "ana", "action": "login", "device": {"os": "iOS"}}'),
('{"user": "tom", "action": "buy", "device": {"os": "Android"}}');
SELECT data ->> '$.user' AS user,
data ->> '$.device.os' AS os
FROM events
WHERE json_extract(data, '$.action') = 'buy';
Running total with a window function
SELECT name,
salary,
SUM(salary) OVER (ORDER BY salary DESC) AS running_total,
RANK() OVER (ORDER BY salary DESC) AS salary_rank
FROM employees;
Recursive CTE
WITH RECURSIVE chain(id, name, level) AS (
SELECT id, name, 0 FROM employees WHERE manager_id IS NULL
UNION ALL
SELECT e.id, e.name, c.level + 1
FROM employees e
JOIN chain c ON e.manager_id = c.id
)
SELECT substr('........', 1, level * 2) || name AS org_chart
FROM chain;
sqlite3 shell commands and their SQL versions
| sqlite3 shell | Here |
|---|---|
.tables | SELECT name FROM sqlite_master WHERE type = 'table'; |
.schema employees | SELECT sql FROM sqlite_master WHERE name = 'employees'; |
PRAGMA table_info / .schema columns | SELECT * FROM pragma_table_info('employees'); |
.indexes | SELECT name, tbl_name FROM sqlite_master WHERE type = 'index'; |
.import file.csv | Import .sql / .csv button (creates the table and inserts the rows) |
.mode csv / .output | Export CSV under any result table |
Learning SQL? Try the SQL practice questions, 30 exercises on these same databases with instant checking.
Frequently asked questions
Is this real SQLite?
Yes. It is SQLite 3.54 compiled to WebAssembly (sql.js) and running in your browser, so SQLite syntax and functions behave as they do in the sqlite3 library.
Where is my data stored?
In your browser's memory. Nothing is sent to a server. Your queries are saved in this browser so they are there next time; the tables are rebuilt from the sample when you reload or press Reset database.
Why does .tables not work?
Dot commands such as .tables, .schema and .mode belong to the sqlite3 command-line shell, not to SQL. Use SELECT name FROM sqlite_master WHERE type = 'table'; or the Schema tab instead.
Can I open my own SQLite database or CSV file?
You can import a .sql dump or a .csv file with the Import button; a CSV becomes a new table. Binary .db files are not supported yet.
Which SQLite features are supported?
Window functions, recursive CTEs, JSON functions and the ->> operator, UPSERT with ON CONFLICT, RETURNING, STRICT tables, generated columns, RIGHT and FULL OUTER JOIN and FTS4. FTS5 and math functions such as pow() and sqrt() are not in this build.
Is it free?
Yes. SQLite Online, the sample databases, CSV import and export and share links are free and need no account.
Related tools
- SQL Practice Questions with Answers30 SQL exercises from SELECT to joins, subqueries and window functions, checked instantly in your browser.
- SQL Online Compiler: Run SQLite and PostgreSQL QueriesRun SQL online in your browser with SQLite or PostgreSQL. Sample databases, schema view, one result table per query, CSV import and export. Free, no sign-up.
- MySQL Online Compiler: Run MySQL Queries Online FreeRun MySQL 8.4 queries online on a real MySQL server. Sample databases, schema view, one result table per query, AUTO_INCREMENT, procedures and triggers. Free, no sign-up.