3 ms·
It's a display feature in the "psql" client program. Normal result: column1 | column2 | column3 ---------+---------+--------- 1 | a
by jeffdavis 14y ago
It's a display feature in the "psql" client program.
Normal result:
column1 | column2 | column3
---------+---------+---------
1 | a | 9.9
2 | b | 19.9
(2 rows)
Using \x:
-[ RECORD 1 ]-
column1 | 1
column2 | a
column3 | 9.9
-[ RECORD 2 ]-
column1 | 2
column2 | b
column3 | 19.9
The first form is tabular and works well for a few columns; but doesn't work well when there are many columns, because the lines start to wrap. So you use \x for wide tables to make the result readable (but, obviously, fewer rows are shown at a time).
Using "\x auto" automatically chooses which format to use based on your terminal width.
- joevandyk 14y agoNice! I tried using it for a result that contains really wide columns. I'm seeing a screen full of hyphens separating the rows. You'd think that the hyphens would stretch across just one line of the screen, instead of across the whole result set. See https://img.skitch.com/20120910-fn1abpp3w94yhg63hc8yemt4a4.png https://img.skitch.com/20120910-fn1abpp3w94yhg63hc8yemt4a4.p...
- jeffdavis 14y agoOh, interesting. That's a problem for very wide fields, which aren't going to be handled very well even using \x. \x was meant to handle large numbers of fields, or slightly wider fields. But you're right, maybe that could be cleaned up a little more.
- daniellockard 14y agoOh so like Mysql "\G" command.