-- GB SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024*1024),2),' GB') AS 'Total Index Size' FROM information_schema.TABLES WHERE table_schema='db_name'; -- MB SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024),2),' MB') AS 'Total Index Size' FROM information_schema.TABLES WHERE table_schema='db_name';
SELECT CONCAT(ROUND(SUM(data_length)/(1024*1024*1024),2),' GB') AS 'Total Data Size' FROM information_schema.TABLES WHERE table_schema='db_name';
SELECT CONCAT(table_schema,'.',table_name) AS 'Table Name', CONCAT(ROUND(table_rows/1000000,2),'M') AS 'Rows', CONCAT(ROUND(data_length/(1024*1024*1024),2),'G') AS 'Data Size', CONCAT(ROUND(index_length/(1024*1024*1024),2),'G') AS 'Index Size', CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),2),'G') AS 'Total' FROM information_schema.TABLES WHERE table_schema='db_name';
適用於容量規劃、分庫分表前評估、索引膨脹監控。