technology and zen of life

“A heisenbug (named after the Heisenberg Uncertainty Principle) is a computer bug that disappears or alters its characteristics when an attempt is made to study it.”

Horizontal Scrolling for MySQL queries in Linux

Everyone who works with databases on a linux terminal faces this issue at some point in time — executing select * on a table with too many columns. And in linux since there is no horizontal scrolling, the output is wrapped and hence completely unusable.

You can use

--pager

property to get rid of that text wrap.

Option 1

mysql -u<username> -p --pager="less -S" <database>

 

Option 2

Install a program known as “most”

sudo apt-get install most

And use this to invoke your mysql client

mysql -u<username> -p --pager="most" <database>

 

most is easier to use then less -S and the shortcuts makes it a breeze to run through all the data.

Note – Look the the bottom of the screen while running most to see Options or just read the man page.

If you any other option for viewing data on a terminal let us know!

Leave a Reply

3 Responses

  1. robanderson says:

    This is awesome – exactly what I was looking for

  2. comradeMauzer says:

    Awesome.this kicks ass. I used to just do \G and limit for long rows which was PITA.

  3. Evert Mouw says:

    Nice! I didn’t know “most” and also was not aware of the pager option of mysql.

Email Subscription

Disclaimer

The views expressed on this blog are personal. We do not claim to be a representative voice of the views of any organisation whatsoever. We are not responsible for the content present on the blogs to which we have linked.Views expressed are solely that of the author and does not reflect a collective opinion of contributors.
%d bloggers like this: