You need a local PostgreSQL server and the psql command-line client. If you've been following the Up and Running with SQL course, you already have this.
psql --versionYou should see something like psql (PostgreSQL) 16.x. If not, install PostgreSQL first — the course covers this for macOS, Windows, and Linux.
psql -U postgresYou should land in a prompt that looks like postgres=#.
From the psql prompt:
CREATE DATABASE sql_exercise;Then connect to it:
\c sql_exerciseYour prompt should now say sql_exercise=#. This is where you'll run all the exercises.
Some sections include a schema.sql (the tables) and a seed.sql (sample rows). To load them, from your terminal (not inside psql):
psql -U postgres -d sql_exercise -f 01-up-and-running-with-sql/02-working-with-tables/schema.sqlEach section's exercises.md tells you which files to load.
If you break something and want a clean slate, just re-run the schema.sql for that section — every schema file starts with DROP SCHEMA IF EXISTS ... CASCADE; so it's safe to re-run.
| Command | What it does |
|---|---|
\l |
List all databases |
\c db_name |
Connect to another database |
\dn |
List schemas in current database |
\dt schema.* |
List tables in a schema |
\d table_name |
Describe a table |
\q |
Quit psql |
\? |
Show all psql commands |
You're ready. Start with 01-up-and-running-with-sql/.