MySQL查询表的数据大小,以MB显示

SELECT table_name,
       table_rows,
       ROUND(data_length / 1024 / 1024, 2)                  as data_size_mb,
       ROUND(index_length / 1024 / 1024, 2)                 as index_size_mb,
       ROUND((data_length + index_length) / 1024 / 1024, 2) as total_size_mb
FROM information_schema.tables
WHERE table_schema = '数据库名'
  AND table_name = '表名';