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
.
Written by Lucas
Related protips
1 Response
nice
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mysql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#