
What I Learned Today: MySQL Shell Commands
This is a quick one that I learned from a co-worker. He was in the MySQL shell and instead of ending his query with a semi-colon, like I normally use, he used \G
. The results are interesting, instead of results showing in rows with the fields as columns, results are displayed vertically. Each record is separated by a row number and each field is on a newline with the field name.
"Normal" Query Syntax
+--------------------------+---------+--------------------------+------------+-------------------+ | aid | type | callback | parameters | label | +--------------------------+---------+--------------------------+------------+-------------------+ | comment_publish_action | comment | comment_publish_action | | Publish comment | | comment_save_action | comment | comment_save_action | | Save comment | | comment_unpublish_action | comment | comment_unpublish_action | | Unpublish comment | +--------------------------+---------+--------------------------+------------+-------------------+
Alternative Vertical Results
*************************** 1. row *************************** aid: comment_publish_action type: comment callback: comment_publish_action parameters: label: Publish comment *************************** 2. row *************************** aid: comment_save_action type: comment callback: comment_save_action parameters: label: Save comment *************************** 3. row *************************** aid: comment_unpublish_action type: comment callback: comment_unpublish_action parameters: label: Unpublish comment
Other Quick Commands
Also, you can use \g
in place of a semi-colon. Another one I found on the MySQL command list page just now was \e
, which opens your text editor and allows you to edit the query. I know I can use this when I mistype part of a query that I was breaking up into multiple lines.
Add new comment