====== MySQL - シェルで枠まで出力する ====== 下記のようなテーブルがある # mysql -u root testdb -e 'select * from table1' +------+------+ | id | name | +------+------+ | 1 | A | | 2 | B | | 3 | C | | 4 | D | | 5 | E | | 6 | F | +------+------+ リダイレクトしたり、パイプでつなげたりすると枠は消えてしまいます。 # mysql -u root testdb -e 'select * from table1' > /tmp/aaa # cat /tmp/aaa id name 1 A 2 B 3 C 4 D 5 E 6 F たまにこの枠も欲しい場合がある。 「--table」を付けると枠も一緒に出力してくれます。 # mysql -u root testdb --table -e 'select * from table1' > /tmp/aaa # cat /tmp/aaa +------+------+ | id | name | +------+------+ | 1 | A | | 2 | B | | 3 | C | | 4 | D | | 5 | E | | 6 | F | +------+------+ {{tag>mysql}}