Free Lesson

What Is SQL?

SQL (Structured Query Language) is the standard language for asking a database questions and changing its data. You write short, English-like commands such as SELECT title FROM songs WHERE year > 2020, and the database sends back exactly the rows you asked for.

IBM researchers Donald Chamberlin and Raymond Boyce created it in the early 1970s as SEQUEL, which is why many people still say “sequel” as well as “S-Q-L”. It became an ANSI standard in 1986 and is now understood by PostgreSQL, MySQL, SQLite, SQL Server and Oracle. New to databases? Start with what a database is, then run a query below.

Interactive demo

SQL query demo

Run your first SQL query

Start with a lesson, or build your own query against the 8-row songs table. Press Run to see the result grid. Everything runs in your browser; nothing is sent anywhere.

SELECT these columns

All or none ticked means SELECT *.

query.sql

SELECT *
FROM songs;

SELECT * means every column. FROM names the table. This is the first query almost everyone writes.

Press Run to see the result

Quick SQL quiz

Six questions on what SQL is and what it does.

  1. What does SQL stand for?
  2. Which keyword picks the columns you want?
  3. Which clause keeps only matching rows?
  4. What does ORDER BY plays DESC do?
  5. Is SQL a programming language?
  6. Which command adds a new row?

Real world

What is SQL used for?

Apps and websites

When you log in, check an order or scroll a feed, the app usually runs SQL behind the scenes to fetch your rows.

Business reports

Analysts write SQL to answer questions like last month's sales by region, then feed the result into dashboards.

Data science and AI

Before training a model or building a chart, data scientists pull and clean the data they need with SQL.

Phones and browsers

SQLite, a tiny SQL database, ships inside every iPhone, Android phone and major web browser to store local data.

Compare

SQL vs Excel

AspectSQLExcel
What it isA language for asking a database questionsA spreadsheet app you click and type into
How much dataMillions or billions of rowsUp to 1,048,576 rows per sheet, and slow well before that
How you workWrite a query once, rerun it any timeFilter, sort and copy by hand, or with formulas
SharingMany people and apps read the same live dataCopies of the file drift apart over time
Best forApps, large or shared data, repeatable reportsQuick personal analysis, budgets, small lists

You do not have to choose: many people pull data with SQL, then explore it in a spreadsheet.

The commands

The five families of SQL commands

Every SQL statement falls into one of five groups. Beginners spend most of their time in the first two. Some books fold SELECT into DML; the idea is the same.

DQL Data Query Language

Ask questions and read data

SELECT title FROM songs;

DML Data Manipulation Language

Add, change and delete rows

INSERT INTO songs (title, year) VALUES ('New Song', 2026);

DDL Data Definition Language

Create and change tables

CREATE TABLE songs (title TEXT, year INTEGER);

DCL Data Control Language

Decide who may see or change data

GRANT SELECT ON songs TO analyst;

TCL Transaction Control Language

Save or undo a group of changes

COMMIT;  -- or ROLLBACK;

Honest answer

Is SQL hard to learn?

The basics are easy; mastery takes practice. SQL has a small core vocabulary and reads like a sentence, so most beginners write useful queries on day one. The hard parts come later: joining many tables correctly, thinking in sets instead of loops, and making big queries fast.

A 7-day SQL starter path

  1. Day 1: SELECT and FROM

    Read whole tables, then pick only the columns you need.

  2. Day 2: WHERE

    Filter rows with =, >, <, AND, OR and LIKE.

  3. Day 3: ORDER BY and LIMIT

    Sort results and keep the top rows.

  4. Day 4: COUNT, SUM and AVG

    Summarize data with aggregate functions.

  5. Day 5: GROUP BY

    Get totals per group, like plays per artist.

  6. Day 6: JOIN

    Combine two tables that share a key, like songs and artists.

  7. Day 7: A real question

    Load a free sample database such as SQLite's Chinook and answer one question you care about.

Writing SQL with AI?

Code Card turns your Claude Code, Codex, and OpenClaw sessions into a public developer profile with activity graphs, streaks, badges, and a shareable card, so you can track your coding progress. Start with npx code-card.

Make your Code Card

FAQ

SQL questions, answered

What is SQL in simple terms?

SQL (Structured Query Language) is the standard language for asking a database questions and changing its data. You write short commands like SELECT title FROM songs WHERE year > 2020, and the database returns the matching rows.

What is SQL used for?

SQL is used to read, add, update and delete data stored in relational databases. Apps use it to load your account and orders, analysts use it for reports and dashboards, and data scientists use it to pull data for charts and AI models.

Is SQL hard to learn?

Basic SQL is one of the easiest technical skills to learn. Most beginners can write useful SELECT, WHERE and ORDER BY queries in a day or two. JOINs, grouping and performance tuning take a few weeks of practice.

Is SQL a programming language?

Yes. SQL is a declarative query language: you describe the result you want and the database works out how to get it. It is not usually used to build whole apps on its own, so it is often paired with Python, JavaScript or another general-purpose language.

What is the difference between SQL and MySQL?

SQL is the language. MySQL is one database product that understands SQL, like PostgreSQL, SQLite, Microsoft SQL Server and Oracle. Each adds a few extras of its own, but the core SELECT, INSERT, UPDATE and DELETE commands work almost the same everywhere.