SQL Online Compiler

Write and run SQL queries online with SQLite or PostgreSQL, right in your browser. Sample databases, a schema view and results as tables. Free, no sign-up.

1 total executions (1 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.

Easy SQL Basics

ORDER BY & LIMIT

Sort query results and keep only the first few rows.

Easy SQL Basics

DISTINCT

Remove duplicate rows from a result and count unique values.

Easy SQL Basics

LIKE, IN & BETWEEN

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

Medium SQL Basics

NULL Values

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

Easy Aggregates & GROUP BY

COUNT, SUM, AVG, MIN & MAX

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

Medium Aggregates & GROUP BY

GROUP BY

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

Medium Aggregates & GROUP BY

HAVING

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

How to run SQL online

  1. Pick an engine: SQLite or PostgreSQL. Both run inside your browser, so your data never leaves your computer.
  2. Start from a sample database (Employees or Shop) or an empty one, and look at its tables on the Schema tab.
  3. Write your queries and press Run SQL or Ctrl + Enter. Each statement gets its own result table; select part of the code to run only that.
  4. Export any result as CSV, or press Share to copy a link with your queries.

SQLite or PostgreSQL?

SQLitePostgreSQL
Best forLearning SQL, quick tests, interviewsPractising the SQL of a real server: window functions, JSON, strict types
Start timeInstantA few seconds on the first run (it downloads about 3 MB)
TypesFlexible: any value fits any columnStrict: INTEGER, NUMERIC, DATE, JSONB and more
Runs onYour browser, with no account and no server

MySQL syntax is close to both for everyday queries (SELECT, JOIN, GROUP BY, subqueries). Features only MySQL has, such as AUTO_INCREMENT or backtick quotes, need small changes.

SQL queries to try

  • Filter and sort: SELECT name, salary FROM employees WHERE salary > 6000 ORDER BY salary DESC;
  • Group and count: SELECT department_id, COUNT(*) FROM employees GROUP BY department_id;
  • Join two tables: SELECT e.name, d.name FROM employees e JOIN departments d ON d.id = e.department_id;
  • Window function: SELECT name, salary, RANK() OVER (ORDER BY salary DESC) FROM employees;
  • Your own table: CREATE TABLE, INSERT, UPDATE and DELETE all work; Reset database brings the sample back.

Frequently asked questions

Which SQL databases can I use?

SQLite and PostgreSQL. Both run in your browser, so there is nothing to install and no account to create. SQLite starts instantly; PostgreSQL downloads about 3 MB on its first run.

Is my data sent to a server?

No. The database lives in your browser tab. Queries, imported files and results stay on your computer, and closing the tab removes the database.

Can I run several queries at once?

Yes. Write as many statements as you like, separated by semicolons. Each one gets its own result table, and selecting part of the code runs only that part.

Can I import my own data?

Yes. Import a .sql file to run its statements, or a .csv file to load it into a new table named after the file.

Does it work for MySQL queries?

Everyday MySQL queries such as SELECT, JOIN, GROUP BY and subqueries run the same way. MySQL-only syntax, such as AUTO_INCREMENT or backtick quotes, needs small changes.

Is it free?

Yes. The SQL editor, the sample databases and the CSV export are free and need no account.