mysql 如何查看表的大小
1.查看所有数据库容量大小
1 2 3 4 5 6 7 8 9 | select table_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.tables group by table_schema order by sum(data_length) desc, sum(index_length) desc; |
2.查看所有数据库各表容量大小
1 2 3 4 5 6 7 8 | select table_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.tables order by data_length desc, index_length desc; |
3.查看指定数据库容量大小
例:查看mysql库容量大小:代码如下:
select table_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.tables where table_schema='mysql';
4.查看指定数据库各表容量大小*
例:查看mysql库各表容量大小
select table_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.tables where table_schema='mysql' order by data_length desc, index_length desc;
分类:
mysql
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2019-02-19 RPM打包原理、示例、详解及备查