查看MySQL库中各个表记录数

说明,此方法只适合数据库库中表的记录数是较小的情况下,线上可以考虑采用,要是数据库的表特别的大的话,就不要采用此方法了,负责会导致mysql的服务器的负载特别的高,有可能导致服务器被挂掉的风险。

for n in `mysql -uroot -p'12334' -e "use  novel;show tables;"|sed '1d'`;do echo $n; mysql -uroot -p'12334' -e "use  novel;select count(*) from $n;";done >test.txt
  • 1.
[root@git-server ~]# cat test11.txt 
fpagent
count(*)
1
fpagentprop
count(*)
0
fpagentsession
count(*)
0
fpchatsetting
count(*)
51
fpdispatcher
count(*)
1
fpdispatcherprop
count(*)
0
fpofflinesetting
count(*)
0
fpqueue
count(*)
1
fpqueueagent
count(*)
1
fpqueuegroup
count(*)
0
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.

查看数据库中的所有表采用的引擎类型:
root@localhost [ksdatas]>select table_name,engine from information_schema.tables where table_schema = ‘ksdatas’;

posted @ 2018-05-24 18:07  勤奋的蓝猫  阅读(2)  评论(0编辑  收藏  举报  来源