MySQL查询数据库表空间大小

一、查询所有数据库占用空间大小

SELECT TABLE_SCHEMA, CONCAT( TRUNCATE(SUM(data_length) / 1024 / 1024, 2),  MB ) AS data_size, CONCAT( TRUNCATE(SUM(index_length) / 1024 / 1024, 2), MB ) AS index_size FROM information_schema.tables GROUP BY TABLE_SCHEMA ORDER BY data_length DESC;

 

二、查询对应数据库表占用空间大小

1 SELECT TABLE_NAME, CONCAT( TRUNCATE(data_length / 1024 / 1024, 2),  MB ) AS data_size, CONCAT( TRUNCATE(index_length / 1024 / 1024, 2),  MB ) AS index_size FROM information_schema.tables WHERE TABLE_SCHEMA = 数据库名字 GROUP BY TABLE_NAME ORDER BY data_length DESC;

 

三、查询某个数据库对应表占用空间大小

SELECT CONCAT( ROUND(SUM(DATA_LENGTH / 1024 / 1024), 2), MB ) AS DATA FROM TABLES WHERE table_schema = 数据库名字 AND table_name = 表名字;

 

MySQL查询数据库表空间大小

上一篇:SQL2005使用多个备份设备和镜像备份设备提高备份速度


下一篇:Maven中的SNAPSHOT版本和正式版本