20
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

これは便利!MySQLの結果を縦表示にする方法

Posted at

うちの新人が知らなかったので、
小ネタとして。。。

見本用に適当にテーブルを作り、データを用意しました。
※ここでは割愛します。

とりあえずSELECTで中身を見てみます。

mysql> SELECT * FROM sample;

+------+----------+------------+-------+-------+-------+-------+-------+-------+-------+---------------------+---------------------+
| id   | password | is_deleted | text1 | text2 | text3 | text4 | text5 | text6 | text7 | created             | modified            |
+------+----------+------------+-------+-------+-------+-------+-------+-------+-------+---------------------+---------------------+
| 1    | test     | 0          | aaa     | bbb     | ccc     | ddd     | eee     | fff     | ggg     | 2019-06-25 20:00:00 | 2019-06-24 20:00:00 |
+------+----------+------------+-------+-------+-------+-------+-------+-------+-------+---------------------+---------------------+
1 row in set (0.00 sec)

デフォルトだと横長で表示されるので、
ウィンドウのサイズによって見づらかったりします。

そこで今度は;を\Gに変えます。
そうすると...

mysql> SELECT * FROM sample\G

*************************** 1. row ***************************
        id: 1
  password: test
is_deleted: 0
     text1: aaa
     text2: bbb
     text3: ccc
     text4: ddd
     text5: eee
     text6: fff
     text7: ggg
   created: 2019-06-25 20:00:00
  modified: 2019-06-24 20:00:00
1 row in set (0.00 sec)

まとめ

このように縦に表示されて見やすくなりました。

参考

MySQL 5.6 リファレンスマニュアル
https://dev.mysql.com/doc/refman/5.6/ja/mysql-commands.html

20
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?