SQLite Online

Run SQLite queries online, right in your browser. SQLite 3.54 with sample databases, a schema view and results as tables. Nothing to install, free, no sign-up.

483 total executions (483 this month)
Embed

Press Run SQL to see the results here.

Test your SQL with quizzes

Short quizzes with code to read and run: answer, see the explanation, and earn XP and badges.

All SQL quizzes
Easy SQL Basics

SELECT & WHERE

Pick the columns you want and keep only the rows that match a condition.

What this quiz covers
  • Choosing columns with SELECT and SELECT *
  • Filtering rows with WHERE and comparison operators
  • Combining conditions with AND, OR and parentheses
#select#filtering
10 questions · ~5 min · 4 plays Start
Easy SQL Basics

ORDER BY & LIMIT

Sort query results and keep only the first few rows.

What this quiz covers
  • Sorting with ORDER BY, ASC and DESC
  • Breaking ties with a second sort column
  • Keeping the first rows with LIMIT and skipping rows with OFFSET
#sorting#select
10 questions · ~5 min · 2 plays Start
Easy SQL Basics

DISTINCT

Remove duplicate rows from a result and count unique values.

What this quiz covers
  • Removing duplicate rows with SELECT DISTINCT
  • DISTINCT applies to the whole row, not one column
  • Counting unique values with COUNT(DISTINCT column)
#select#duplicates
10 questions · ~5 min · 1 play Start
Easy SQL Basics

LIKE, IN & BETWEEN

Filter rows with text patterns, lists of values and ranges.

What this quiz covers
  • Pattern matching with LIKE, % and _
  • Case sensitivity of LIKE in SQLite, MySQL and PostgreSQL
  • Checking a list of values with IN and NOT IN
#filtering#patterns
10 questions · ~5 min · 1 play Start
Medium SQL Basics

NULL Values

Learn how SQL treats missing values in comparisons, calculations and filters.

What this quiz covers
  • Why = NULL never matches and IS NULL does
  • NULL in arithmetic and comparisons like <>
  • Replacing missing values with COALESCE
#null#filtering
10 questions · ~6 min · 1 play Start
Easy Aggregates & GROUP BY

COUNT, SUM, AVG, MIN & MAX

Turn many rows into one number with the five core aggregate functions.

What this quiz covers
  • Counting rows with COUNT(*)
  • Totals and averages with SUM and AVG
  • MIN and MAX on numbers and text
#aggregates#select
10 questions · ~5 min Start
Medium Aggregates & GROUP BY

GROUP BY

Split rows into groups and calculate a total, count or average for each one.

What this quiz covers
  • One result row per group with GROUP BY
  • Aggregates per group like SUM, COUNT and AVG
  • Grouping by more than one column
#group-by#aggregates
10 questions · ~6 min Start
Medium Aggregates & GROUP BY

HAVING

Filter groups by their totals, counts or averages after GROUP BY.

What this quiz covers
  • Filtering groups with HAVING
  • WHERE (rows, before grouping) vs HAVING (groups, after)
  • Using WHERE and HAVING in the same query
#having#group-by
10 questions · ~6 min Start

How to use SQLite online

  1. Start from a sample database (Employees or Shop) or an empty one, and look at its tables on the Schema tab.
  2. 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.
  3. Your tables stay while the page is open, so you can run CREATE TABLE once and query it many times. Reset database brings the sample back.
  4. Import a .sql dump or a .csv file, export any result as CSV, or press Share to copy a link with your queries.
  5. 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, STRICT tables, generated columns, RIGHT and FULL OUTER JOIN.
  • The sqlite3 shell's dot commands are not SQL, so .tables and .schema do not work here. Use SELECT name FROM sqlite_master WHERE type = 'table'; and SELECT * FROM pragma_table_info('employees'); instead, or open the Schema tab.
  • Math functions such as pow() and sqrt() 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

tables.sql Run this code
SELECT name, sql
FROM sqlite_master
WHERE type = 'table';

Dates with strftime and date modifiers

dates.sql Run this code
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

upsert.sql Run this code
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

json.sql Run this code
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

window.sql Run this code
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

recursive.sql Run this code
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 shellHere
.tablesSELECT name FROM sqlite_master WHERE type = 'table';
.schema employeesSELECT sql FROM sqlite_master WHERE name = 'employees';
PRAGMA table_info / .schema columnsSELECT * FROM pragma_table_info('employees');
.indexesSELECT name, tbl_name FROM sqlite_master WHERE type = 'index';
.import file.csvImport .sql / .csv button (creates the table and inserts the rows)
.mode csv / .outputExport 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.