Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Performance & internals
Stage 5: Specialization

Part 01 / Topic 5 of 10

Meeting psql

psql is the standard PostgreSQL client: a prompt where you type SQL and see results. It ships with every Postgres install, works everywhere, and is the tool every Postgres engineer actually uses — so it is the tool this course uses.

Connect (macOS/Linux; on Windows open "SQL Shell (psql)"):

$ psql -d postgres
psql (17.10)
Type "help" for help.

postgres=#

Read the prompt: postgres is the database you are connected to, and =# means you are a superuser (=> for a regular user). To leave, type \q and press Enter.

Two kinds of things get typed at this prompt:

  • SQL statements — end with a semicolon ;, sent to the server: SELECT 1;
  • psql commands — start with a backslash \, handled by psql itself, no semicolon: \q

If you press Enter and nothing happens, look at the prompt: postgres-# (with a -) means psql is still waiting for the ; that ends your statement. Type ; and press Enter.

🧪 Quick quiz — answer from memory, then check.

  1. How do you leave psql?
  2. The prompt changed from =# to -#. What is psql telling you?
Show the answers
  1. \q (a psql command — no semicolon needed).
  2. Your statement isn't finished — it is waiting for the closing ;.

Done here? The practice set for Part 1 — 6 exercises with solutions — is on the part page.

Search the guide