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:

shell terminal
psql -U postgres -d storefront
Output
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:

psql exploring a database
\l
\c storefront
\dt
\d products
\q
What each one does
\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
Note: a semicolon ends a SQL statement, not a meta-command — typing \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

SQL storefront=#
SELECT current_database(), current_user;
Output
 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.