views:

625

answers:

3

I'm using Putty (Command-line) and running a

mysql> SELECT * FROM sometable;

The 'sometable' has many fields and this results in many columns trying to be displayed in the terminal. The fields wrap onto the next line so it is very hard to line up Column titles with Field values.

What solutions are there for viewing such data in terminal?

(p.s. I don't have/want access to phpMyAdmin - or other GUI interfaces)

Looking for command-line solutions such as this Save MySQL Query results into text or CVS file (save-mysql-query-results-into-a-text-or-csv-file)

+2  A: 
SELECT * FROM sometable\G

displays the rows like this:

*************************** 1. row ***************************
             id: 1
Rytmis
+1  A: 

Try enabling vertical mode, using "\G" to execute the query instead of ";", i.e. mysql> SELECT * FROM sometable \G

Your results will be listed in the vertical mode, so each column value will be printed in separate line. The output willbe narrower but obviously much longer

Swiety
A: 

I believe putty has a maximum number of columns you can specify for the window.

For Windows I personally use Windows PowerShell and set the screen buffer width reasonably high. The column width remains fixed and you can use a horizontal scroll bar to see the data. I had the same problem you're having now.

edit: For remote hosts that you have to SSH into you would use something like plink + Windows PowerShell

Patrick Gryciuk