psql and other tools
🏠The everyday picture
A records office has a counter for quick requests (fast, precise, a bit terse) and a reading room with comfortable tables and catalogues (easier to browse).
📘What it really is
- psql is PostgreSQL's command-line client:
psql "$DATABASE_URL". Useful commands (they start with a backslash): \llist databases;\c crmconnect to one;\dtlist tables;\d customersdescribe a table;\dulist roles;\i file.sqlrun a SQL file;\timingshow how long each query takes;-
\qquit. -
Graphical tools: pgAdmin (official), DBeaver (free, works with many databases), TablePlus, or the table editor in Supabase and Neon's dashboards.
-
Careful with graphical editors on real data: clicking and editing cells is quick, but there's no
WHEREto check and no review. For anything that matters, write SQL, check it with a SELECT, and use a transaction (Modules 55 and 57). -
Run your migrations from Module 58 against PostgreSQL. You'll need small changes from SQLite's SQL (next lesson); this is normal when moving databases, and another reason to keep all SQL in migrations and repositories.
🖱️Try it
Connect with psql. Turn on \timing. Run your migrations with \i (adapting any SQLite-only syntax), then \dt and
\d orders to check the structure. Insert your sample data and run three of your report queries from Module 56.
✅Quick check
How do you see the structure of the orders table in psql?
Show the answer
\d orders.
Why prefer SQL scripts over editing cells in a graphical tool for real changes?
Show the answer
SQL can be checked with a SELECT first, run in a transaction, reviewed and repeated; clicking can't.
