MySQL view the size of the space occupied by the table

SELECT CONCAT(table_schema,'.',table_name) AS 'Table Name',   
    table_rows AS 'Number of Rows',   
    CONCAT(ROUND(data_length/(1024*1024*1024),6),' G') AS 'Data Size',   
    CONCAT(ROUND(index_length/(1024*1024*1024),6),' G') AS 'Index Size' ,   
    CONCAT(ROUND((data_length+index_length)/(1024*1024*1024),6),' G') AS'Total'  
FROM information_schema.TABLES   
WHERE table_schema = SCHEMA()
+-------------------------------------------------------+----------------+------------+------------+
| Table Name                           | Number of Rows | Data Size      | Index Size | Total      |
+-------------------------------------------------------+----------------+------------+------------+
| demo.table1                          |       13379763 | 2.936523 G     | 0.246964 G | 3.183487 G |
| demo.table2                          |       13655221 | 2.965820 G     | 0.251862 G | 3.217682 G |
| demo.table3                          |       40621029 | 9.108398 G     | 0.722656 G | 9.831055 G |
| demo.table4                          |       13808962 | 2.763672 G     | 0.232300 G | 2.995972 G |
| demo.table5                          |       13771353 | 2.864258 G     | 0.241104 G | 3.105362 G |
| demo.table6                          |       13782027 | 2.878906 G     | 0.242081 G | 3.120987 G |
+-------------------------------------------------------+----------------+------------+------------+
6 rows in set (0.01 sec)

Guess you like

Origin blog.csdn.net/xchenhao/article/details/126857617