Introduction
PostgreSQL (often just "Postgres") is a free, open-source relational database that's been under active development since the 1980s. It speaks standard SQL — everything from the site's SQL course works here unchanged — and then goes further with a genuinely rich type system, extensibility, and features like the ones this course covers.
Connecting with psql
psql is PostgreSQL's official command-line client. Once PostgreSQL is installed and running, you connect to a specific database with:
psql -U postgres -d storefront
psql (16.2) Type "help" for help. storefront=#
-U postgres picks the database user to connect as, and -d storefront picks which database to connect to. The storefront=# prompt means you're connected and ready to type SQL — the # specifically means the connected user is a superuser; a regular user would see storefront=> instead.
Meta-commands: psql's own shortcuts
Anything starting with a backslash is a psql client command, not SQL — it never gets sent to the database itself:
\l \c storefront \dt \d products \q
\l list all databases on the server \c connect to a different database \dt list tables in the current database \d describe one table's columns and types \q quit psql
\dt; works only because psql ignores the trailing semicolon, but ordinary SQL like SELECT * FROM products genuinely needs one, and psql will keep waiting on a continuation prompt until it sees it.Your first real query
SELECT current_database(), current_user;
current_database | current_user -------------------+--------------- storefront | postgres (1 row)
This is exactly the row-and-column result format every example in this course will show — a header row, a line of dashes separating it from the data, and a (N rows) summary at the bottom. That's psql's own formatting, produced automatically for any query that returns rows.