本文翻译自:Alternate output format for psql
I am using PostgreSQL 8.4 on Ubuntu. 我在Ubuntu上使用PostgreSQL 8.4。 I have a table with columns c1
through cN
. 我有一个表,其中的列c1
到cN
。 The columns are wide enough that selecting all columns causes a row of query results to wrap multiple times. 列足够宽,选择所有列都会导致一行查询结果多次包装。 Consequently, the output is hard to read. 因此,输出难以读取。
When the query results constitute just a few rows, it would be convenient if I could view the query results such that each column of each row is on a separate line, eg 当查询结果仅占几行时,如果我可以查看查询结果以使每一行的每一列都位于单独的行(例如,
c1: <value of row 1's c1>
c2: <value of row 1's c1>
...
cN: <value of row 1's cN>
---- some kind of delimiter ----
c1: <value of row 2's c1>
etc.
I am running these queries on a server where I would prefer not to install any additional software. 我在不希望安装任何其他软件的服务器上运行这些查询。 Is there a psql setting that will let me do something like that? 是否有一个psql设置可以让我做类似的事情?
#1楼
参考:https://stackoom.com/question/EiCT/psql的备用输出格式
#2楼
Also be sure to check out \\H, which toggles HTML output on/off. 另外,请务必检查出\\ H,它会打开/关闭HTML输出。 Not necessarily easy to read at the console, but interesting for dumping into a file (see \\o) or pasting into an editor/browser window for viewing, espe