失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 实战:mysql统计指定架构的所有表的数据和索引大小情况【MySQL】

实战:mysql统计指定架构的所有表的数据和索引大小情况【MySQL】

时间:2021-06-09 03:38:33

相关推荐

实战:mysql统计指定架构的所有表的数据和索引大小情况【MySQL】

数据库|mysql教程

数据库-mysql教程

#统计指定架构的所有表的数据和索引大小情况

#tablesize.sh

#!/bin/sh

#ocpyang@

怎么下载cms网站php源码下载,ubuntu磁盘阵列,tomcat二级域名映射,爬虫python数据应用,php数组中怎么删除某个对象,里水seo优化lzw

if [ “$#” -gt 2 ];then

echo “**********************************”

echo “too many input parameters”

echo “**********************************”

echo “USAGE01: $0 schema_name table_name”

echo “eg01: $0 wind t1”

echo “USAGE02: $0 schema_name “

echo “eg02: $0 wind “

exit 1;

fi

会员录入系统php源码,ubuntu rm -f,tomcat 新连接池,乌龟像爬虫,php增删改查视频,渝中抖音搜索seo优化排名lzw

source /usr/local/mysql/scripts/mysql_env.ini

logfiledate=tmp.`date +%Y%m%d%H%M%S`.txt

html 获取网页源码,ubuntu6.10安装,tomcat7更改内存,web爬虫安全,php制作api格式,百度seo关键词优化推广平台lzw

SCHEMA_NAME=$1

TABLE_NAME=$2

if [ “$#” -eq 2 ];then

SQL_CMD=”select table_schema, table_name,table_rows,

round(sum(data_length+index_length)/1024/1024) as total_MB,

round(sum(data_length)/1024/1024) as data_MB,

round(sum(index_length)/1024/1024) as index_MB

from information_schema.tables where table_type=’BASE TABLE’ and table_schema=’${SCHEMA_NAME}’

and table_name=’${TABLE_NAME}’

group by table_schema, table_name,table_rows;”

else

SQL_CMD=”select table_schema, table_name,table_rows,

round(sum(data_length+index_length)/1024/1024) as total_MB,

round(sum(data_length)/1024/1024) as data_MB,

round(sum(index_length)/1024/1024) as index_MB

from information_schema.tables where table_type=’BASE TABLE’ and table_schema=’${SCHEMA_NAME}’

group by table_schema, table_name,table_rows;”

fi

SCHEMA_JUDEGE=”select * from information_schema.schemata where schema_name=’${SCHEMA_NAME}’;”

mysql -h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS} -e”${SCHEMA_JUDEGE}” >${logfiledate}

if [ -e “${logfiledate}” -a ! -s “${logfiledate}” ];then

echo “you input ${SCHEMA_NAME} not exits,pleae check your databases”

rm -rf ${logfiledate}

else

echo “the result is :”

mysql -h${MYSQL_HOST} -u${MYSQL_USER} -p${MYSQL_PASS} -e”${SQL_CMD}”

rm -rf ${logfiledate}

fi

如果觉得《实战:mysql统计指定架构的所有表的数据和索引大小情况【MySQL】》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。