The SELECT statement is how you read data from a table. Use SELECT * to retrieve every column from a row.
The FROM clause specifies which table to read. Every query needs at least a SELECT and a FROM. Try changing employees to departments to see a different table.
SQL Playground — Learn SQL with Real PostgreSQL in Your Browser, Free
What's included
Features
About this tool
Learn SQL Online with a Real PostgreSQL Engine — No Install, No Sign-Up
Most people learning SQL hit the same wall: the tutorial shows you the syntax, but you have no database to actually run it against. Setting up PostgreSQL locally means installing a server, creating a database, connecting a client, and loading sample data — before you even write your first SELECT. This playground eliminates that friction entirely.
Open the page and you have a working PostgreSQL database in your browser, pre-loaded with realistic sample data across four related tables: employees, departments, projects, and assignments. Write any SQL query, press Ctrl+Enter or click Run, and see the results in a table below. No installation, no account, no loading screen on subsequent visits — PostgreSQL runs directly in your browser using PGlite, a real PostgreSQL engine compiled to WebAssembly.
The tool is structured as 39 lessons across 10 chapters that take you from beginner to pro: from the very first SELECT statement through filtering, sorting, aggregations, JOINs, subqueries, CTEs, window functions, and PostgreSQL-specific features, and finally into a professional Indexes, Transactions & Performance chapter — creating indexes, reading a query plan with EXPLAIN ANALYZE, BEGIN/COMMIT/ROLLBACK transactions, upserts with ON CONFLICT, and saving queries as views. Each lesson has a short concept explanation and a pre-written starter query that you can run as-is or modify to experiment. Lessons are designed so you can run the starter query, understand what it produces, then change the WHERE clause, add a column, or adjust the ORDER BY to see how the result changes — because that experimentation is how SQL actually sticks.
SQL is worth mastering because it is the universal language of data: every relational database (PostgreSQL, MySQL, SQL Server, SQLite) speaks it, and it remains one of the most in-demand skills for developers, analysts, and data scientists. The concepts here transfer directly to any database job — and because this playground runs a *real* PostgreSQL engine, what you learn is exactly what runs in production.
The schema stays consistent across all lessons: a small company with employees (with salaries, hire dates, manager references, and JSONB metadata), departments (with budgets and locations), projects (with statuses and dates), and assignments linking employees to projects with hours worked. This means by lesson 20 the data feels familiar — you're not learning new tables, you're learning new ways to query the same ones.
Progress is tracked automatically in localStorage. Your completed lessons and current position are remembered between sessions, so you can close the tab and pick up exactly where you left off. The schema explorer in the sidebar shows every table with its column names and types, so you always know what data is available without leaving the editor.
Step by step
How to Use
- 1Pick a lesson from the sidebarThe left sidebar lists all 39 lessons grouped by chapter. Start at the beginning (SELECT all columns) or jump to a pro chapter — Indexes, Transactions & Performance — that matches your level. Each lesson title tells you exactly what concept it covers.
- 2Read the concept explanationA collapsible panel above the editor shows a short explanation of the SQL concept for that lesson — what it does, how it works, and what to watch out for. Click the panel header to collapse it if you want more editor space.
- 3Run the starter queryEach lesson opens with a pre-written SQL query. Press Ctrl+Enter (or click the Run button) to execute it. The results appear in the table below. PostgreSQL loads from CDN on first use — this takes a few seconds; subsequent queries run instantly.
- 4Experiment by modifying the queryChange the WHERE clause, add a column, adjust the ORDER BY, or try writing the same query a different way. The editor supports Tab for indentation. If you break something, click Reset to restore the lesson's starter query.
- 5Check the schema explorerThe bottom section of the sidebar shows all four tables with their column names and PostgreSQL data types. Expand it to see what columns are available — useful when writing joins or filtering on a column you've forgotten the name of.
- 6Mark the lesson done and move to the nextOnce you're comfortable with a concept, click Mark Done. Your progress is saved automatically. Use the Previous/Next buttons at the bottom to navigate between lessons, or click any lesson in the sidebar to jump directly to it.
Real-world uses
Common Use Cases
Got questions?
Frequently Asked Questions
It uses PGlite — a real PostgreSQL engine compiled to WebAssembly. When the page loads, it downloads the PostgreSQL WASM binary from CDN (a few seconds on first load) and creates an in-memory PostgreSQL database in your browser. Queries run against real PostgreSQL, so you get accurate error messages, real type handling, and support for all standard PostgreSQL features including JSONB, window functions, and recursive CTEs.
Yes, completely private. PostgreSQL runs entirely inside your browser — the database lives in memory in your browser tab and is never sent anywhere. When you close the tab, the database is gone. Your query text, your results, and your progress data (stored in localStorage) never leave your machine.
The database has four related tables: employees (id, name, department_id, salary, hire_date, manager_id, metadata JSONB), departments (id, name, location, budget), projects (id, name, status, start_date, department_id), and assignments (employee_id, project_id, role, hours_worked). The schema explorer in the sidebar shows all columns and types. The data represents a small tech company with 12 employees across 5 departments and 5 projects.
Yes. The editor is a full SQL editor — you can clear the starter query and write anything you want. CREATE TABLE, INSERT, SELECT, JOIN, aggregations, CTEs, window functions, and PostgreSQL-specific features all work. You can even modify the existing data with UPDATE or INSERT statements. The only limitation is that the database resets when you reload the page.
SQL (Structured Query Language) is the standard language for querying relational databases. PostgreSQL is a specific database engine that implements SQL but adds many powerful extensions: JSONB columns, ILIKE for case-insensitive matching, array types, the RETURNING clause, full-text search, and more. The first 8 chapters of this playground teach standard SQL that works in any database. The final chapter covers PostgreSQL-specific features.
The first time you click Run, the tool downloads the PostgreSQL WebAssembly binary from CDN (~10–15MB), initialises the database engine, and loads the sample data. This typically takes 3–8 seconds depending on your connection. Every subsequent query runs in milliseconds because the engine is already loaded and the database is already initialised. You'll see a "Loading PostgreSQL engine…" message while this happens.
Most browser-based SQL tools either connect to a shared remote database (introducing latency and privacy concerns), use a simplified JavaScript SQL interpreter (which doesn't support real PostgreSQL syntax), or require you to create an account. This playground runs real PostgreSQL entirely in your browser via WebAssembly — no server, no account, no interpreter. It's also structured as guided lessons rather than a blank editor, making it more useful for learning than for ad-hoc querying.
Yes. When a SELECT query returns results, a CSV button appears in the results panel header. Click it to download all returned rows as a CSV file named results.csv. The export includes the column names as the header row and handles values that contain commas or quotes correctly.
Window functions compute a value across a set of rows related to the current row, without collapsing them into a single row the way GROUP BY does. They're used for rankings (ROW_NUMBER, RANK), comparing rows to their neighbours (LAG, LEAD), computing running totals (SUM OVER ORDER BY), and calculating per-group statistics alongside individual row data (PARTITION BY). The Window Functions chapter has four lessons that cover each of these patterns with queries you can run and modify.
Yes. Completed lessons and your current lesson position are saved automatically in your browser's localStorage. When you reopen the page, you'll return to the lesson you were on. Progress is stored per browser — it won't sync across devices. If you clear your browser storage or use a private window, progress starts fresh.