LoginSignup
2
2

More than 5 years have passed since last update.

MySQLのDBからテーブルの平均カラム数を計算する

Posted at

MySQLのDBからテーブルの平均カラム数を計算する

尚、以下のワンライナーはEC-CUBE用のため、grepでテーブル名を限定しているところは読み替えていただきたく。

echo 'show tables' | mysql -u $DBUSER -p$DBPASS $DBNAME | grep dtb | grep -v 'seq$' | awk '{print "desc " $1 ";"}' | while rea
d LINE;do echo $LINE | mysql -u $DBUSER -p$DBPASS $DBNAME | wc -l ;done | awk 'BEGIN{cnt=0}{cnt+=1;sum+=$1}END{print sum/cnt}'
2
2
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
2