1

Is there a way to show data from the table in a more clean way? For example: SHOW COLUMNS FROM my_table; shows a clean display of each column with the type of data it contains and this information is displayed vertically.

enter image description here

SELECT * FROM my_table WHERE uid=99999; However, when I select one record from this table, the results are jumbled because the screen is not wide enough for a clean view. Is it possible to display the columns on the left instead when just looking at one row?

enter image description here

Thanks!

AZinkey
  • 5,209
  • 5
  • 28
  • 46
Christia
  • 251
  • 3
  • 18
  • 1
    Sorry, after I figured out how to word my question, I found the answer here: http://stackoverflow.com/questions/11134569/how-to-show-records-vertically-in-mysql-command-line – Christia Apr 25 '17 at 21:19
  • 1
    u deserve self-learner badge :)) – George G Apr 25 '17 at 21:20

2 Answers2

3

The \G modifier in the MySQL command line client

A little publicized, but exceedingly useful feature of the MySQL command line client is the \G modifier. It formats the query output nicely, so you can read through it easier. To use it, you just replace the semi-colon at the end of the query with \G.

For example,

mysql> SHOW MASTER STATUS;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000193 |     7061 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

mysql> SHOW MASTER STATUS\G
*************************** 1. row ***************************
            File: mysql-bin.000193
        Position: 7061
    Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)
AZinkey
  • 5,209
  • 5
  • 28
  • 46
1

You can configure mysql to do this automatically by configuring it in a my.cnf file

[mysql]
  auto-vertical-output

This way, you can continue to use ; as a statement terminator, and any query output that exceeds the terminal width will automatically switch to the vertical mode.

This can be a hassle when the output switches that way when you don't want it, e.g. output from a mysql -Bse '...' command that you want to pipe to something else.

In that case, you override the the auto switching with mysql --auto-vertical-output=false ...

dland
  • 4,319
  • 6
  • 36
  • 60