Skip to main content
Kill -9 Club
Sign in

psql

DatabasesPackage: postgresql-client

PostgreSQL's interactive client. psql -c runs a query from a script; \l, \dt and \du answer the first three questions — which databases, which tables, which roles.

What its options do in the lessons

From the same glossary the lessons render under their commands, so the two cannot disagree.

psql -c
Runs a single query and exits, without opening an interactive session.
psql -d
Which database to connect to.
psql -U
The PostgreSQL role to connect as.
psql -h
The host. Naming it makes the connection go over TCP rather than the Unix socket — which changes the pg_hba.conf line that applies.
psql -t
Output with no header and no footer: the rows alone.
psql -A
Unaligned output, easier for a script to split.

Lessons that teach it