Last Updated: February 25, 2016
·
2.823K
· x3ro

Vertically displaying columns in MySQL query

When using the MySQL command line client, it is usually unwise to write a query like

SELECT * FROM foo;

because you will end up with a really wide table that gets broken up into multiple lines by your terminal, and it probably be hard to know which values belongs to a column:

Looks familiar? Well then, \G to the rescue!

SELECT * FROM foo \G

This query will instead return a neat, vertical representation of your data (especially useful if you're only looking at a single row):

*************************** 1. row ***************************
 username: Foobar
 disable: 0
 usergroup: 1
 ...

Note that there must not be a semicolon before or after the \G.

1 Response
Add your response

nice

over 1 year ago ·