Reference

Cheat Sheet

The commands you keep forgetting, with a one-line description and a real example you can copy - 384 across 26 tools. Pick a tool in the sidebar, or search across all of them.

psql (Postgres)

The PostgreSQL command-line client - connect, inspect, and run SQL.
CommandWhat it doesExample
psql connectConnect to a database.psql -h localhost -U postgres -d mydb
psql (URL)Connect with a connection string.psql postgresql://ana:secret@localhost:5432/mydb
\lList databases.\l
\cSwitch to another database.\c mydb
\dtList tables.\dt
\dDescribe a table (columns, indexes).\d users
\dnList schemas.\dn
\duList roles / users.\du
\xToggle expanded (row-per-column) output.\x
\timingShow how long each query takes.\timing
\iRun SQL from a file.\i seed.sql
\copyImport/export a table as CSV.\copy users TO 'users.csv' CSV HEADER
\eEdit the current query in your $EDITOR.\e
\qQuit psql.\q