How to best display in Terminal a MySQL SELECT returning too many fields?

后端 未结 12 870
你的背包
你的背包 2020-12-04 04:32

I\'m using PuTTY to run:

mysql> SELECT * FROM sometable;

sometable has many fields and this results in many columns trying

12条回答
  •  情深已故
    2020-12-04 05:06

    Using mysql's ego command

    From mysql's help command:

    ego          (\G) Send command to mysql server, display result vertically.

    So by appending a \G to your select, you can get a very clean vertical output:

    mysql> SELECT * FROM sometable \G
    

    Using a pager

    You can tell MySQL to use the less pager with its -S option that chops wide lines and gives you an output that you can scroll with the arrow keys:

    mysql> pager less -S
    

    Thus, next time you run a command with a wide output, MySQL will let you browse the output with the less pager:

    mysql> SELECT * FROM sometable;
    

    If you're done with the pager and want to go back to the regular output on stdout, use this:

    mysql> nopager
    

提交回复
热议问题