Skip to content

PostgreSQL

How to run psql with optimized pager settings

This allows e.g. horizontal scrolling in less and syntax highlighting in bat.

Terminal window
PSQL_PAGER=<MY_PAGER> psql -h localhost ...

A few examples:

Terminal window
PSQL_PAGER='less -SXFRi' psql -h localhost ...
PSQL_PAGER='bat --wrap=never' psql -h localhost ...

How to describe a PostgreSQL table

\d+ <TABLENAME>

How to list all tables in a PostgreSQL database

\dt