查看表空间大小
select TABLE_SCHEMA,TABLE_NAME,TABLE_ROWS ,
concat(round(data_length/1024/1024,2),'MB') as data_size,
concat(round(index_length/1024/1024,2),'MB') as index_size
from information_schema.tables
where table_schema='test' order by data_length asc,index_size asc;
查看分区表各分区的表空间大小
SELECT
TABLE_SCHEMA,TABLE_NAME,PARTITION_NAME,
TABLE_ROWS,
SUBPARTITION_NAME,
concat(round(data_length/1024/1024,2),'MB') as data_size,
concat(round(index_length/1024/1024,2),'MB') as index_size
FROM
INFORMATION_SCHEMA.PARTITIONS
WHERE
TABLE_SCHEMA = 'test' and PARTITION_NAME is not null
order by data_length asc,index_size asc;
或者登录机器进入数据目录对应的库执行 ls -lShr