Photo by chuttersnap on Unsplash

The wonder of psql client’s expanded view (auto)

Niel de Wet

--

When using the psql command line client one inevitably faces a result set that is too wide to fit into the width of your terminal. In such a case one may wish to transpose the output or to view it in a way that is more digestible. Here’s a problematic example:

Wrapping makes reading result set difficult

“Expanded view” makes it possible to view rows as a list of documents of key-value pairs, with the column name as the key. “Expanded view” has three options: “on”, “off” and “auto”. Enable it with the \x command.

\x auto

With the “auto” setting the result set will be displayed in expanded view if it is too big to fit into the terminal width, or in the normal rows and columns otherwise, as can be seen in this example:

Expanded view “auto”

--

--

No responses yet