psql command reference (backslash commands also work in psql -f scripts):
Exploration
\l list databases
\c dbname connect to a database
\dn list schemas
\dt list tables in the current search_path
\dt schema.* list tables in a specific schema
\dt *.* list every table everywhere
\d table describe a table (columns, types, indexes, constraints)
\d+ table describe a table verbosely (storage, comments)
\di list indexes
\dv list views
\dm list materialized views
\df pattern list functions whose name matches
\du list roles (users/groups)
\dx list installed extensions
Help
\? list all meta-commands
\h list SQL commands
\h SELECT help on the SELECT statement
Session/output
\x toggle expanded display (column-per-line)
\timing toggle showing query timing
\pset pager off disable the less-style pager
\pset format aligned default table format; alternatives include csv, html, unaligned
\a toggle "unaligned" mode (use format csv for CSV escaping)
\o file redirect query output to a file (\o without arg disables)
Files and scripts
\i file.sql run a SQL script from inside psql
\ir file.sql run relative to the current script
\copy table FROM 'file.csv' WITH (FORMAT csv, HEADER true) client-side import
\copy (SELECT ...) TO 'file.csv' WITH (FORMAT csv, HEADER true) client-side export
Editing
\e open the last query in $EDITOR (or write a new one)
\ef function_name open a function definition in $EDITOR
\ev view_name open a view definition in $EDITOR
\q quit