Online SQL - IDE, Editor, Compiler, Interpreter

Practise SQL online: create tables, insert data and run queries against a real SQLite database in your browser. Results appear as tables.

SQLite 3 (sql.js) · Runs in your browser, so your code never reaches our servers.
main.sqlSQL
Output

            
        
Ctrl/⌘ + Enter to run

Features of the online SQL compiler (IDE, editor & interpreter)

Write, run and test SQL code online for free. This page works as an online SQL IDE, code editor, compiler and interpreter in one: type your code, press Run and see the output straight away. Everything runs in your browser, with nothing to install and no account to create.

  • Run code instantly: SQLite 3 (sql.js), with output in under a second after the first load.
  • Code editor: syntax highlighting, line numbers, bracket matching and auto-closing brackets.
  • Clear errors: error messages and warnings appear in the output panel, as they would on your own computer.
  • Full screen: Ctrl/⌘ + Shift + F, adjustable font size, side-by-side or stacked layout and resizable panes.
  • Autosave: your code is kept in your browser; download it as main.sql or copy it in one click.
  • Safe to experiment: a time limit and a Stop button end infinite loops.
  • Private: the SQL runtime runs on your device, so your code is never uploaded.
  • Dark mode and keyboard shortcuts: Ctrl/⌘ + Enter runs the code.
  • Free: no sign-up, no usage limits.

Learn other programming languages

How to use the online SQL compiler

  1. Write your SQL in the editor. You can create tables (CREATE TABLE), add data (INSERT) and query it (SELECT) in a single script. Separate statements with semicolons.
  2. Press Run or use Ctrl + Enter (⌘ + Enter on a Mac).
  3. Every statement that returns rows is shown as its own result table, in order, with a row count underneath. NULL values are labelled as such. If no statement returns rows, you'll see a short confirmation instead.
  4. Choose a time limit of 5, 15 or 60 seconds, which is useful for runaway recursive queries. Stop cancels a query immediately.

The SQLite engine is small, well under 1 MB, so it loads almost instantly. Reset example restores the sample employees schema, and main.sql downloads your script.

Your queries run in a Web Worker in your own browser. Neither the SQL nor the data is uploaded or stored on our servers. The editor keeps your last script in your browser's local storage, and in no other place.

What's supported

The compiler runs SQLite 3 through sql.js, the SQLite C library compiled to WebAssembly. It is a real relational database engine, not an emulator.

  • DDL and DML: CREATE TABLE, CREATE INDEX, CREATE VIEW, INSERT, UPDATE, DELETE, constraints, foreign keys and triggers.
  • Queries: joins, subqueries, GROUP BY/HAVING, UNION, CASE, and common table expressions, including WITH RECURSIVE.
  • Window functions such as ROW_NUMBER(), RANK(), LAG() and running totals with SUM() OVER (...).
  • Built-in functions for text (substr, upper, replace), numbers, and dates (date, strftime).

Limitations:

  • A fresh, empty in-memory database each run. Tables do not survive between runs, so keep your CREATE and INSERT statements at the top of the script.
  • It is SQLite, not MySQL or PostgreSQL. Most standard SQL works, but vendor-specific features such as stored procedures, GRANT, MySQL's AUTO_INCREMENT keyword or PostgreSQL's SERIAL type do not.
  • Large result sets show the first 1,000 rows, along with the total row count.
  • You cannot connect to an external database or open your own .db file.

SQL quick reference

CREATE TABLE orders (
  id       INTEGER PRIMARY KEY,
  customer TEXT NOT NULL,
  amount   REAL,
  placed   TEXT DEFAULT (date('now'))
);

INSERT INTO orders (customer, amount) VALUES
  ('Ada', 120.0), ('Ada', 35.5), ('Grace', 80.0);

WITH totals AS (
  SELECT customer, SUM(amount) AS spent, COUNT(*) AS n
  FROM orders
  GROUP BY customer
)
SELECT customer, spent, n
FROM totals
WHERE spent >= 50 AND n <> 0
ORDER BY spent DESC;
TaskSQL
Auto-numbered keyid INTEGER PRIMARY KEY
Filter rowsWHERE price BETWEEN 10 AND 20
Pattern matchWHERE name LIKE 'A%'
Concatenate textfirst || ' ' || last
PaginateLIMIT 10 OFFSET 20
Replace NULLCOALESCE(phone, 'n/a')
Insert or updateINSERT ... ON CONFLICT(id) DO UPDATE SET ...

Tips

  • Use sqlite_master to list what you have created: SELECT name, sql FROM sqlite_master;
  • Use EXPLAIN QUERY PLAN SELECT ... to see whether a query uses an index.
  • SQLite uses flexible typing: a column declared INTEGER can still store text. Add CHECK constraints, or use STRICT tables, when you want type enforcement.
  • Foreign keys are only enforced after PRAGMA foreign_keys = ON;.
  • Long, messy query? Clean it up with the SQL formatter before you share it.
Tip: Wrap repeated inserts in BEGIN; … COMMIT;. Generating test data with a recursive CTE is a quick way to fill a table with thousands of rows for practice.

Frequently asked questions

Which SQL dialect does this use?

SQLite 3. It follows standard SQL closely, so it is well suited to learning SELECT, joins, grouping and window functions. Syntax specific to MySQL, PostgreSQL or SQL Server may need small changes.

Is my data saved?

No. Each run creates a new in-memory database, which is deleted as soon as the run ends. Only the SQL text in the editor is remembered, locally in your browser.

Can I run several queries at once?

Yes. Separate them with semicolons. Statements run in order, and each one that returns rows produces its own result table.

Can I practise with other languages too?

Yes. Try the online Python compiler, where Python's built-in sqlite3 module works too, or browse all our developer tools.

Copied to clipboard