Just added: Algorithms you can run and practice
Reference

Cheat Sheet

The commands you keep forgetting, with a one-line description and a real example you can copy - 629 across 38 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
psql -cRun one query and exit.psql -U postgres -d mydb -c "SELECT count(*) FROM users;"
\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
pg_dumpBack up a database to a plain SQL file.pg_dump -U postgres mydb > backup.sql
pg_dump -FcCompressed custom-format backup (for pg_restore).pg_dump -Fc -U postgres mydb > mydb.dump
pg_restoreRestore a custom-format backup.pg_restore -U postgres -d mydb mydb.dump
restore (plain SQL)Replay a plain SQL backup with psql itself.psql -U postgres -d mydb < backup.sql
\eEdit the current query in your $EDITOR.\e
\qQuit psql.\q