1.查看指定库数据和索引大小总和
select concat(round(sum((data_length+index_length)/1024/1024),2),'MB') as total_data from information_schema.TABLES where table_schema = 'work';
2..查看所有库数据和索引大小总和
select concat(round(sum((data_length+index_length)/1024/1024),2),'MB') as total_data from information_schema.TABLES;
3.查看指定数据库的某个表
select concat(round(sum((data_length+index_length)/1024/1024),2),'MB') as data from tables where table_schema='work' and table_name='user';
4.查询一个库中每个表的数据大小,索引大小和总大小
SELECT
CONCAT(ROUND(data_length/(1024*1024),4),',') AS 'data_size',
CONCAT(ROUND(index_length/(1024*1024),4),'M') AS 'index_size',
CONCAT(ROUND((data_length+index_length)/(1024*1024),4),'M') AS'Total'
FROM
information_schema. TABLES a
WHERE
a.table_schema = 'work'