mysql 查看表的大小方法:1、查看所有数据库各表容量大小,代码为【truncate(data_length/1024/1024, 2) as '数据容量(MB)'】;2、查看指定数据库各表容量大小。
1.查看所有数据库容量大小
select table_schema as '数据库', su~ R n ^ mm(tabl d h y k Oe_rows) as '记S V W e X . @录数v 4 x', sum(truncate(data_length/1024/1024, 2)) as '数据容量(MB)', sum(truncate(index_length/1024/1024, 2)) asf c 7 3 '索引容量(MB)' from information_schk ? o o g M Wema.tables group by t/ % a c l ^ _ - Jable_schema order by sum(data_length) desc,y c # sum(index_length) desc;
2.查看所有数据库各表容量大小
select table_schema as '数据库', table_name as '表名', ta9 + + )ble_rows as '记录数',A L @ } m truncate(data_length/1024/1024, 2) as '数据容量(MB)', truncate(index_length/1024/1024, 2) as '索引容量(M} ; q & [ u ? #B)' fro! O m * S ~ Em inforx 4 m $mation_s0 ] 8 Q y u a 9chema.tables order by data_length desc, index_length desc+ o C D 1 * F;
3.查看指定数据库容量大小
例:查看mysql库容量大小
selC Q I *ect table_schema as '数据库', sum(table_rows) as '记录数', sum(truncate(data_length/1024/1024, 2)) as '数据容q a o量(MB)', sum(truncate(index_length/1024/1024, 2)) as '索引容量(MB)'d | y fr. o J F t + som information_schema.tables where table_schema='mysql';
4.查看指定数据库各表容量大小
例:查看mysql库各表容量大小
select table_schema as '数据库', table_name as '表名',2 7 { table_rows as '记录数', truncate(data_length/1024/1024L * 2 b C /, 2) as '数据容量(! # y yMB)', 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教程
以上v l P 1 s Z a就是mysql 如何查看表的大小的详细内容。