SkillSha LogoSkillSha
Developer Tool · Free

SQL Online Compiler: Write and Run SQL on a Sample Database

Practise SQL without installing anything. This online SQL editor runs a real SQLite engine in your browser, preloaded with a realistic college database. Write a query, press Run (or Ctrl + Enter) and see results instantly.

How to use the online SQL editor

  1. 1Pick an example from the chips above the editor, or type your own query.
  2. 2Press Run SQL or Ctrl/Cmd + Enter. Multiple statements separated by ; run in order.
  3. 3Results appear as tables with row counts and execution time.
  4. 4Browse the schema panel to see every table, column and primary key. Click a table name to preview it.
  5. 5Experiment freely with INSERT, UPDATE, DELETE or CREATE TABLE — click Reset database to start fresh.

Sample database schema

The practice database models a small college and its staff:

  • departments (dept_id, dept_name, location)
  • students (student_id, name, email, city, dept_id → departments, year, cgpa)
  • courses (course_id, title, dept_id → departments, credits, fee)
  • enrollments (enrollment_id, student_id → students, course_id → courses, grade, enrolled_on)
  • employees (emp_id, name, role, dept_id → departments, salary, manager_id → employees, hired_on)

SQL commands you can practise

SELECT … WHERE … ORDER BY

Filter and sort rows

GROUP BY + COUNT/SUM/AVG/MIN/MAX

Summarise data

INNER / LEFT JOIN

Combine related tables

HAVING & subqueries

Filter groups and nest queries

INSERT / UPDATE / DELETE

Change data

CREATE TABLE / DROP TABLE

Define and remove tables

Example: top student in each department

This query joins students to departments and uses a correlated subquery to find the highest CGPA per department:

SELECT d.dept_name, s.name, s.cgpa
FROM students s
JOIN departments d ON d.dept_id = s.dept_id
WHERE s.cgpa = (
  SELECT MAX(cgpa) FROM students WHERE dept_id = s.dept_id
)
ORDER BY s.cgpa DESC;

Copy it into the editor and run it. Then try changing MAX to MIN, or add WHERE d.location = 'Block A'.

Why practise SQL here

  • Zero setup — no database installation, accounts or downloads.
  • Safe sandbox: nothing you run can affect real data.
  • Realistic relational data for interview and placement test practice.
  • Helpful error messages that suggest the right table name when you make a typo.
SQL is a core skill for data analyst and data science roles. Go further with Skillsha’s Data Analytics course.

Frequently asked questions

Is this SQL online compiler free?

Yes. It is completely free, needs no sign-up, and works on desktop and mobile browsers.

Which SQL dialect does it use?

It runs SQLite compiled to WebAssembly. Standard SQL such as SELECT, INSERT, UPDATE, DELETE, CREATE TABLE, DROP TABLE, JOINs, GROUP BY, HAVING, subqueries and aggregate functions works the same way it does in MySQL or PostgreSQL. A few vendor-specific features (stored procedures, some date functions) differ.

Is my SQL sent to a server?

No. The database is created inside your browser tab. Your queries never touch Skillsha’s servers or any production database, and everything resets when you refresh.

What tables are in the sample database?

departments, students, courses, enrollments and employees — linked with foreign keys so you can practise joins, grouping and subqueries on realistic data.

Can I create my own tables?

Yes. Run CREATE TABLE and INSERT statements; the schema panel updates immediately. Use Reset database to return to the original sample data.

How do I run multiple queries at once?

Separate statements with semicolons. Each statement’s result appears as its own table or success message, in order.