MySQL console tip
If you terminate statements with \G
instead of ;
, the MySQL console will print the result set vertically rather than as a horizontal table.
For example, instead of:
+----+--------+--------+
| id | foo_id | bar_id |
+----+--------+--------+
| 1 | 6 | 2 |
+----+--------+--------+
You will have:
*************************** 1. row ***************************
id: 186
foo_id: 6
bar_id: 2
It’s really useful for wide tables, or ones with text columns.
I’m always surprised that the MySQL docs don’t make it easier to find this – it’s one of the better tricks for using the database console.