MYSQL怎么查找数据库中表的大小
1、查询数据库中所有表的大小
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='table_schema(数据库名称)'
order by data_length desc, index_length desc;
其中“table_schema”就是数据库名称
2、查询mysql数据库的大小:
select
sum(truncate(data_length/1024/1024, 2)) +
sum(truncate(index_length/1024/1024, 2)) as '数据容量(MB)'
from information_schema.tables
where table_schema='table_schema(数据库名称)'
3、查看指定数据库的某个表的大小
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='table_schema(数据库名称)' and table_name='table_name(表名称)'
order by data_length desc, index_length desc;