mysqlsqlpostgresqlterminal

Easily viewing postgresql and mysql results that are too wide for the terminal


I regularly use postgresql and mysql in the mac terminal, and I find that results that have a large number of columns become very difficult to interpret because the entire table becomes a mess. I have seen a command in postgresql that showed each row as a table of it's own (with each column having its own row), and it was very useful for checking the output of a small number of rows with a large number of columns. Does anybody know how this is done, and is there a similar technique for mysql?

Thanks.


Solution

  • You can use a better pager than default more

    try to use in shell

    export PAGER=less
    export LESS="-iMSx4 -RSFX -e"
    

    and then in psql:

    \pset pager always
    

    other possibility is using a \x command to switch from column view to row view.

    It should to work on all SQL shells that uses a pager. We used it for Vertica too.