Is there a way to set the max width of a column when displaying JSONB results in psql?

大兔子大兔子 提交于 2021-01-28 09:15:37

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!