mysql で SELECT 文の最後をセミコロンではなくメタコマンドの \G にすると結果を縦に表示してくれる!今まで知りませんでした。カラム数が多い時はかなり便利です。

mysql> select * from wp_posts limit 2;
+----+-------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+---------------+--------------+-------------+----------------+-------------+---------------+-------------+---------+--------+---------------------+---------------------+-----------------------+-------------+-----------------------------+------------+-----------+----------------+---------------+
| ID | post_author | post_date           | post_date_gmt       | post_content                                                                                                                                                | post_title   | post_category | post_excerpt | post_status | comment_status | ping_status | post_password | post_name   | to_ping | pinged | post_modified       | post_modified_gmt   | post_content_filtered | post_parent | guid                        | menu_order | post_type | post_mime_type | comment_count |
+----+-------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+---------------+--------------+-------------+----------------+-------------+---------------+-------------+---------+--------+---------------------+---------------------+-----------------------+-------------+-----------------------------+------------+-----------+----------------+---------------+
|  1 |           1 | 2009-01-30 09:50:15 | 2009-01-30 00:50:15 | WordPress!                                                                                                          | Hello world! |             0 |              | publish     | open           | open        |               | hello-world |         |        | 2009-01-30 09:50:15 | 2009-01-30 00:50:15 |                       |           0 | http://wordpress/?p=1       |          0 | post      |                |             1 |
|  2 |           1 | 2009-01-30 09:50:15 | 2009-01-30 00:50:15 | WordPress ! |            |             0 |              | publish     | open           | open        |               | about       |         |        | 2009-01-30 09:50:15 | 2009-01-30 00:50:15 |                       |           0 | http://wordpress/?page_id=2 |          0 | page      |                |             0 |
+----+-------------+---------------------+---------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------+---------------+--------------+-------------+----------------+-------------+---------------+-------------+---------+--------+---------------------+---------------------+-----------------------+-------------+-----------------------------+------------+-----------+----------------+---------------+
2 rows in set (0.00 sec)

とこうなってしまうのが、\G ( or \g ) をつけると

mysql> select * from wp_posts limit 2\g
*************************** 1. row ***************************
                   ID: 1
          post_author: 1
            post_date: 2009-01-30 09:50:15
        post_date_gmt: 2009-01-30 00:50:15
         post_content: WordPress !
           post_title: Hello world!
        post_category: 0
         post_excerpt:
          post_status: publish
       comment_status: open
          ping_status: open
        post_password:
            post_name: hello-world
              to_ping:
               pinged:
        post_modified: 2009-01-30 09:50:15
    post_modified_gmt: 2009-01-30 00:50:15
post_content_filtered:
          post_parent: 0
                 guid: http://wordpress/?p=1
           menu_order: 0
            post_type: post
       post_mime_type:
        comment_count: 1
*************************** 2. row ***************************
                   ID: 2
          post_author: 1
            post_date: 2009-01-30 09:50:15
        post_date_gmt: 2009-01-30 00:50:15
         post_content: WordPress
           post_title:
        post_category: 0
         post_excerpt:
          post_status: publish
       comment_status: open
          ping_status: open
        post_password:
            post_name: about
              to_ping:
               pinged:
        post_modified: 2009-01-30 09:50:15
    post_modified_gmt: 2009-01-30 00:50:15
post_content_filtered:
          post_parent: 0
                 guid: http://wordpress/?page_id=2
           menu_order: 0
            post_type: page
       post_mime_type:
        comment_count: 0
2 rows in set (0.00 sec)

この通り、大変見やすくなります!
もっと早く知りたかった。。。

関連する投稿