SQL Overview
Objectives
By the end of this lesson, you should be able to:
- Explain what SQL is and what it’s used for
- Name the broad kinds of things SQL statements do
💡 Why this matters: SQL is the actual language this entire course teaches. Before writing any of it, it helps to know what it is and roughly how it’s organized.
What Is SQL?
SQL stands for Structured Query Language. It’s the standard language for talking to a relational database: creating tables, adding and changing data, and asking questions of it. Every RDBMS from the last lesson, PostgreSQL included, understands SQL, with a large shared core and small differences at the edges.
SQL reads close to plain English by design:
SELECT title, price FROM books WHERE price < 15;
Even without knowing the syntax yet, that statement is fairly readable: get the title and price of books that cost less than 15. Making statements like this precise, and knowing exactly what they’ll do, is what the rest of this course builds up to.
The Broad Shape of SQL
SQL statements roughly split into two jobs:
- Statements that define or change the structure of a database, creating a table, adding a column, removing a table.
- Statements that work with the actual data inside tables, reading rows, adding them, changing them, removing them.
This course covers the first kind starting in Module 3 (Creating Tables) and Module 5 (Altering Tables), and the second kind starting in Module 2 (SQL Basics) and Module 4 (CRUD Operations). Keeping this rough split in mind helps make sense of where each new statement fits as it’s introduced.
Try It
- In your own words, explain what SQL is used for.
- Looking at the example query above, guess what
SELECT title, price FROM books;(without theWHEREpart) would return, before you’ve been taughtSELECTformally. - Sort these into “changes structure” or “works with data”: adding a new column to a table, adding a new row to a table, removing a table entirely, reading existing rows.
Recap
- SQL (Structured Query Language) is the standard language for talking to a relational database.
- Every RDBMS understands a large shared core of SQL, with PostgreSQL-specific behavior at the edges.
- SQL statements broadly either change a database’s structure, or work with the data inside it, both are covered across this course.
Next lesson: a closer look at PostgreSQL specifically, and why this course is built around it.