Search code examples
postgresqlcommand-line-interfaceless-unix

When I use the \d+ TABLE command with PostgreSQL, the output wraps


When I try to describe a table in PostgreSQL using \d+ TABLE the output wraps. However, I have expanded mode on. I was wondering if someone has a fix for this?

Expected Output: To not wrap around the screen. If possible it should instead look like the expanded view for PostgreSQL tables.

Output now: It will wrap around the screen.


Solution

  • Use better configuration of pager.

    PAGER="less -S" psql dbname
    

    Less -S allows lines to be truncated rather than wrapping. You can use side scrolling to see the rest of the lines.

    Or you can install pspg - https://github.com/okbob/pspg this is a pager designed specially for database consoles.

    PAGER=pspg psql dbname