Making long SQL output easier to read

I've been doing a ton of MySQL work lately, migrating millions of records of content to a new Drupal platform.

One problem I ran into using the MySQL command-line client was trying to read the output of columns with long text content.

mysql> SELECT cid, nid, uid, subject, comment FROM comments LIMIT 1;
+-----+-----+-----+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| cid | nid | uid | subject                   | comment                                                                                                                                                                                                                                                                                                                                                              |
+-----+-----+-----+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|   7 |  35 |   0 | Thanks for the code.
 
But | Thanks for the code.
 
But where should I keep it?
 
In one of my website contributed modules and themes are mixed with core modules and themes, respectively. It is very difficult to figure out specified modules in that big list. I want to separate them, should I just cut and paste the folder in the sites/all/contrib folder after adding the above code? |
+-----+-----+-----+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

I learned a simple but helpful trick from Cameron Guill (DBA at Morris Digitalworks) to get easier to read output from this kind of query. Instead of ending your query statement with the usual semicolon, instead use "\G" to get the following:

mysql> SELECT cid, nid, uid, subject, comment FROM comments LIMIT 1\G
*************************** 1. row ***************************
    cid: 7
    nid: 35
    uid: 0
subject: Thanks for the code.
 
But
comment: Thanks for the code.
 
But where should I keep it?
 
In one of my website contributed modules and themes are mixed with core modules and themes, respectively. It is very difficult to figure out specified modules in that big list. I want to separate them, should I just cut and paste the folder in the sites/all/contrib folder after adding the above code?
1 row in set (0.00 sec)

That's much nice and much easier to read, isn't it?

Tags: