1. What is SQL?
SQL is the language you use to talk to a database. You write a short sentence that says what you want, and the database figures out how to get it. That's the whole idea.
Almost all the data that runs the world — your bank balance, an online store's orders, a hospital's records — lives in relational databases, and SQL is how you read and change that data. Learn SQL once and it works almost the same in Postgres, MySQL, SQLite, and every other major database.
Data lives in tables
A relational database organizes data into tables. A table is just a grid, like a spreadsheet:
- Each row is one thing (one film, one customer, one order).
- Each column is one fact about that thing (a title, a price, a date).
- Every column has a type — text, number, date — and only holds that kind of value.
This course uses a sample database called pagila: a pretend
DVD-rental store, with tables like film, actor, customer, and
rental. Open the 🗂 Database schema link in the sidebar any time to
see every table and how they connect.
Your first question
To read data you use SELECT. Here's "show me the title and rental
price of every film." Hit Run — it executes right here in your
browser.
SELECT title, rental_rate
FROM film;
Read it like a sentence: select these columns from this table.
title and rental_rate are columns; film is the table. The database
hands you back a result — another table, made just for your answer.
Try it
Change the query below to show each film's title and its length
(how many minutes long it is), instead of the price.
SELECT title, rental_rate
FROM film;
SELECT title, length
FROM film;
That's SQL. The rest of this course is just learning to ask sharper questions — filtering, sorting, combining tables, summarizing — and later, creating and changing the data yourself.