mysql/gbase数据库全库库表记录数统计

时间:2022-02-17 06:30:40

file:mysql_rows.sh

运行:sh mysql_rows.sh 库名

脚本内容:

#!/bin/bash

user=...
pwd=...

ip=...

port=...

 

tb_name=`mysql -u $user -p$pwd -h$ip -P$port -e "select table_name from information_schema.tables where table_schema=$1" |awk ‘NR>1{print $1}‘`
>/date/$1.log
for name in $tb_name ;
do
tbl_count=`mysql -u $user -p$pwd -h$ip -P$port -e "select SQL_CALC_FOUND_ROWS 1 FROM $1.$name limit 1;SELECT found_rows() AS rowcount;"|awk ‘NR==4{print $1}‘`
echo "$name=$tbl_count" >>/date/$1.log
done