Online SQL compiler
Write SQL against a sample database or your own tables and see each result as a table.
Students of classes 11 and 12, their teachers, the courses they teach, and each student's enrollments with marks.
Press Run to see the result. Changes to the database last until you press Reset or reload the page.
Practise with problems
The SQL practice problems use these databases: write the query, press Check, and see whether it returns the right rows.
The sample databases
School
Students of classes 11 and 12, their teachers, the courses they teach, and each student's enrollments with marks.
- courses: id, name, teacher_id, credits
- enrollments: id, student_id, course_id, marks, enrolled_on
- students: id, name, gender, class, section, city, dob, email
- teachers: id, name, subject, city, joined_on
Online shop
Customers from many countries, the products the shop sells, their orders across 2025 and 2026, and the items in each order.
- customers: id, name, city, country, signup_date, phone
- order_items: id, order_id, product_id, quantity, unit_price
- orders: id, customer_id, order_date, status
- products: id, name, category, price, stock
Company
Departments in several cities, the employees in them with their managers and salaries, projects, and the hours people spend on each project.
- assignments: id, employee_id, project_id, hours
- departments: id, name, location
- employees: id, name, department_id, manager_id, job_title, salary, hire_date
- projects: id, name, department_id, budget, start_date, end_date
MySQL and SQLite: what to write here
| To | MySQL | SQLite (here) |
|---|---|---|
| List the tables | SHOW TABLES; | SELECT name FROM sqlite_master WHERE type = 'table'; |
| Describe a table | DESC students; | PRAGMA table_info(students); |
| Join text | CONCAT(name, ' ', city) | name || ' ' || city |
| Auto-numbered key | id INT AUTO_INCREMENT PRIMARY KEY | id INTEGER PRIMARY KEY |
| Today's date | CURDATE() | date('now') |
| Year of a date | YEAR(hire_date) | strftime('%Y', hire_date) |
| First rows | LIMIT 5 | LIMIT 5 (the same) |
Questions
Is my SQL sent to a server?
No. The database lives in your browser, so your queries and tables never leave this page.
Which SQL does it run?
SQLite 3, the database built into Python and most phones. Standard SELECT, JOIN, GROUP BY, subqueries, WITH and window functions all work; the table above shows where MySQL differs.
Can I create my own tables?
Yes. Pick Empty database, then CREATE TABLE and INSERT your rows. Changes last until you press Reset database or reload the page; keep your SQL with Copy link.
Can I use the result in Python?
Run it from Python opens the editor with the same database and query in Python, using sqlite3 and pandas, so you can go on to charts and analysis.