问题
I have a problem that is somewhat similar to this question: Is there a way to set the max width of a column when displaying query results in psql?. I have a number of tables in Postgres with large JSONB documents. When I use psql from Emacs, it grinds to a halt trying to display fields with these documents. Ideally, I just want to see the first X characters of a document when I select *
from a given table. I tried:
\pset columns 20
To no avail. Is there some permutation of columns
and format
that could achieve this? At present I am manually casting columns like so:
cast("PAYLOAD" as varchar(50))
This works, but it does mean I need to remember to cast before selecting which is a major pain.
来源:https://stackoverflow.com/questions/59330565/is-there-a-way-to-set-the-max-width-of-a-column-when-displaying-jsonb-results-in