問い合わせ結果にカラム名を表示しないようにする

MySQL で SQL で問い合わせを行った場合、問い合わせ結果にはカラム名が表示されます。

下記の例だと id、name がカラム名となります。

mysql> SELECT * FROM testtb;
+------+------------+
| id   | name       |
+------+------------+
|    1 | hoge       |
|    2 | hogehoge   |
+------+------------+
2 rows in set (0.05 sec)

MySQL では接続時に -N オプションを指定することで、問い合わせ結果のカラム名を非表示にすることができます。

# mysql -u root -p -N
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 89507
Server version: 5.1.52-log MySQL Community Server (GPL) by Utter Ramblings

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

・・・

mysql> SELECT * FROM testtb;
+------+------------+
|    1 | hoge       |
|    2 | hogehoge   |
+------+------------+
2 rows in set (0.05 sec)

 

[対象]
MySQL 5.x.x