Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

what does '\x auto' do?


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.


Nice!

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.p...


Oh, 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.


Oh so like Mysql "\G" command.


\x in psql switches if things are like a table or a list. Before you'd have to run a query and see that you cant read it, then hit \x and then run the query again. Now you can just have it figure out which one to show you based on your terminal size




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: