brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: \x auto lets psql show wide rows one field per line

Database
~/tips/psql-expanded

\x auto

Makes psql print wide query results one field per line, only when they do not fit.

A table with fifteen columns wraps into a mess in psql. Expanded display fixes that, and there is a setting that only switches it on when needed.

\x auto
SELECT * FROM users LIMIT 2;

\x toggles expanded output, where each row becomes a block with one field per line. \x auto is smarter: psql uses the normal table when it fits on screen and the expanded one when it does not.

While you are there, \timing shows how long each query takes. Both are psql commands, so they start with a backslash and need no semicolon.

Caveat: the setting is gone when you close psql. Put \x auto in ~/.psqlrc to keep it.

Further reading: psql documentation

More Database tips mariadb -e 'CREATE DATABASE IF NOT EXISTS blog' mariadb-dump --no-create-info --insert-ignore shop orders > orders-rows.sql SELECT table_schema, table_name, CHECKSUM TABLE shop.orders; services: All Database tips (53) All topics

Link