一 查询表大小;
SELECT
table_schema AS '数据库',
table_name 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='lost_game_1' AND table_name='player';
二、查看mysql所有表大小
select
table_schema as '数据库',
table_name as '表名',
table_rows as '记录数',
truncate(data_length/1024/1024/1024, 2) as '数据容量(GB)',
truncate(index_length/1024/1024/1024, 2) as '索引容量(GB)'
from information_schema.tables
order by table_schema, data_length desc, index_length desc;