查看MySQL库中各个表记录数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了查看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
[[email protected] ~]# 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

以上是关于查看MySQL库中各个表记录数的主要内容,如果未能解决你的问题,请参考以下文章

MySQL查看库中所有表的大小和记录数

查看mysql库中所有表的信息--INFORMATION_SCHEMA

查看mysql库大小,表大小,索引大小

查看mysql库表大小并排序,清表

[Mysql]备份同库中一张表的历史记录 insert into ..select

Mysql库表记录的基本操作