2
5

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コマンドのpagerの利用

2
Posted at
Page 1 of 6

利用方法

MySQL利用している時に、lessなどのLinuxのコマンド取り入れると、効率を大幅に向上になるでしょう!下記の例でみてみましょう

mysql> pager less 
PAGER set to 'less' 
mysql> show engine innodb status\G

大規模なデータselectの結果をprintしたい場合

mysql> pager cat > /tmp/test.log
PAGER set to 'cat > /tmp/test.log'

checksumを利用して、SQLの変化あるかどうか、確認可能

mysql> pager md5sum 
PAGER set to 'md5sum' 

mysql> SELECT ... 
d1036606f00f07b96c7c141bd41576bd  -

selectの実行時間のみ知りたい場合

mysql> pager cat > /dev/null 
PAGER set to 'cat > /dev/null'

mysql> SELECT ... 
1000 rows in set (0.91 sec) 
 
mysql> SELECT ... 
1000 rows in set (1.63 sec)  

集計したい場合も可能

mysql> pager awk -F '|' '{print $6}' | sort | uniq -c | sort -r
PAGER set to 'awk -F '|' '{print $6}' | sort | uniq -c | sort -r'

mysql> select ... 
      9  vodu0508
      8  vt002010
      6  vt002007
      6  vt002003
      5  vt002008
      5  vt002006
      4  12345678
      3  vt002005
      3  vodu0226
       ... 
2
5
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
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?