如何查看MySQL数据库表容量大小
如何查看MySQL数据库表容量大小?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
1.查看所有数据库容量大小
selecttable_schemaas'数据库',sum(table_rows)as'记录数',sum(truncate(data_length/1024/1024,2))as'数据容量(MB)',sum(truncate(index_length/1024/1024,2))as'索引容量(MB)'frominformation_schema.tablesgroupbytable_schemaorderbysum(data_length)desc,sum(index_length)desc;
2.查看所有数据库各表容量大小
selecttable_schemaas'数据库',table_nameas'表名',table_rowsas'记录数',truncate(data_length/1024/1024,2)as'数据容量(MB)',truncate(index_length/1024/1024,2)as'索引容量(MB)'frominformation_schema.tablesorderbydata_lengthdesc,index_lengthdesc;
3.查看指定数据库容量大小
例:查看mysql库容量大小
selecttable_schemaas'数据库',sum(table_rows)as'记录数',sum(truncate(data_length/1024/1024,2))as'数据容量(MB)',sum(truncate(index_length/1024/1024,2))as'索引容量(MB)'frominformation_schema.tableswheretable_schema='mysql';
4.查看指定数据库各表容量大小
例:查看mysql库各表容量大小
selecttable_schemaas'数据库',table_nameas'表名',table_rowsas'记录数',truncate(data_length/1024/1024,2)as'数据容量(MB)',truncate(index_length/1024/1024,2)as'索引容量(MB)'frominformation_schema.tableswheretable_schema='mysql'orderbydata_lengthdesc,index_lengthdesc;
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。