mysql(27) : 数据量统计

所有数据库数据量查询倒序

SELECT
    a.table_schema ,
    concat(round(sum(DATA_LENGTH / 1024 / 1024) + sum(INDEX_LENGTH / 1024 / 1024) ,2) ,'MB') total_size ,
    concat(round(sum(DATA_LENGTH / 1024 / 1024) , 2) ,'MB') AS data_size ,
    concat(round(sum(INDEX_LENGTH / 1024 / 1024) , 2) ,'MB') AS index_size
FROM
    information_schema.TABLES a
group by a.table_schema
order by sum(DATA_LENGTH / 1024 / 1024) + sum(INDEX_LENGTH / 1024 / 1024)  desc;

指定数据库表数据量查询倒序

SELECT
   a.table_name ,
    concat(round(sum(DATA_LENGTH / 1024 / 1024) + sum(INDEX_LENGTH / 1024 / 1024) ,2) ,'MB') total_size ,
    concat(round(sum(DATA_LENGTH / 1024 / 1024) , 2) ,'MB') AS data_size ,
    concat(round(sum(INDEX_LENGTH / 1024 / 1024) , 2) ,'MB') AS index_size
FROM
    information_schema.TABLES a
    where a.table_schema = 'mysql'
group by a.table_name
order by sum(DATA_LENGTH / 1024 / 1024) + sum(INDEX_LENGTH / 1024 / 1024)  desc;

你可能感兴趣的:(mysql,mysql,数据库,database,数据库数据量统计)