Chạy một truy vấn để xem kết quả.
(Tài liệu bằng tiếng Anh)
What it does
The SQL Playground lets you write and run real SQL queries directly in your browser - no installs, no sign-ups, no data leaving your machine. It ships with a ready-to-query sample database (users + orders) so you can start exploring joins, aggregates, and filters the moment the page loads. Swap in your own schema at any time and the database rebuilds live.
It’s powered by sql.js, a full SQLite engine compiled to WebAssembly. That means you get real SQL behavior - transactions, constraints, aggregates, subqueries - running 100% client-side. Results render in a clean table with row counts and timing, and you can export them as CSV, JSON, or Markdown with one click.
How to use it
- The Schema panel on the left is pre-loaded with a sample
users+ordersdatabase. Edit it freely - the database rebuilds automatically when you stop typing, and a green “applied” badge confirms it worked. - Write your SQL in the Query panel on the right - both editors highlight SQL syntax as you type - or click one of the example query chips (Select all, Filter, Aggregate, Join, Sort + limit, CTE, Subquery, Having, Like + order, Union) to load a pre-built query.
- Click Run (or press ⌘/Ctrl + Enter) to execute.
- Read the Results table below - it shows column headers, typed values (NULLs are styled distinctly), a row count, a read-only badge for SELECT queries, and the elapsed time in milliseconds.
- Use the CSV / JSON / Markdown toggle + Copy results to export the output in your preferred format.
- Click Copy share link to encode your current schema and query into the URL - anyone who opens the link sees your exact setup.
Examples
Join two tables and aggregate
SELECT u.name, u.role, COUNT(o.id) AS orders, SUM(o.amount) AS total
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
GROUP BY u.id
ORDER BY total DESC;
Returns each user with their order count and spend total, sorted highest first. Users with no orders appear with 0 / NULL.
Filter with a subquery
SELECT name, email FROM users
WHERE id IN (SELECT user_id FROM orders WHERE amount > 20);
Returns only users who have placed an order over $20.
Inspect table structure
PRAGMA table_info(users);
Returns column index, name, type, nullability, and default value for every column in the users table - useful for exploring unfamiliar schemas.
Good to know
- 100% client-side. Your SQL and data never leave the browser - everything runs locally via sql.js (SQLite compiled to WebAssembly). Safe for sensitive schemas.
- Live schema editing. Change the Schema panel and the database rebuilds automatically (debounced). Errors are shown inline - queries stay disabled until the schema is valid again.
- SQLite dialect. This is real SQLite - you get window functions, CTEs, JSON functions, and most of the SQLite feature set. A few things (stored procedures, MySQL/Postgres-specific syntax) aren’t supported.
- Shareable. Your schema and query are encoded in the URL, so a shared link reproduces your exact playground state.
- Related tools: Regex Tester, JSON Formatter.