MySQL查看数据库、表容量大小

编程入门 行业动态 更新时间:2024-10-27 19:20:06

MySQL查看数据库、表<a href=https://www.elefans.com/category/jswz/34/1764416.html style=容量大小"/>

MySQL查看数据库、表容量大小

1. 查看所有数据库容量大小
selecttable_schema as '数据库',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'from information_schema.tablesgroup by table_schemaorder by sum(data_length) desc, sum(index_length) desc;

2. 查看所有数据库各表容量大小
 
selecttable_schema as '数据库',table_name as '表名',table_rows as '记录数',truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as '索引容量(MB)'from information_schema.tablesorder by data_length desc, index_length desc;

3. 查看指定数据库容量大小
selecttable_schema as '数据库',sum(table_rows) as '记录数',sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)',sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'from information_schema.tableswhere table_schema='mysql';

4. 查看指定数据库各表容量大小
selecttable_schema as '数据库',table_name as '表名',table_rows as '记录数',truncate(data_length/1024/1024, 2) as '数据容量(MB)',truncate(index_length/1024/1024, 2) as '索引容量(MB)'from information_schema.tableswhere table_schema='crm_mycomm' -- 库名order by data_length desc, index_length desc;

更多推荐

MySQL查看数据库、表容量大小

本文发布于:2023-12-04 12:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1660948.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容量   大小   数据库   MySQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!