# 查看各个库占用空间 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; # 查看某个表占用空间 SELECT concat( round( sum( data_length / 1024 / 1024 ), 2 ), 'MB' ) AS data_length_MB, concat( round( sum( index_length / 1024 / 1024 ), 2 ), 'MB' ) AS index_length_MB FROM information_schema.TABLES WHERE table_schema = 'test' AND table_name = 'test_tb'
其他的补充信息如下
# 查看某个库中的表信息 SELECT table_name, table_type, ENGINE FROM information_schema.TABLES WHERE table_schema = 'db5' ORDER BY table_name # 查看整个实例占用空间 SELECT concat( round( sum( data_length / 1024 / 1024 ), 2 ), 'MB' ) AS data_length_MB, concat( round( sum( index_length / 1024 / 1024 ), 2 ), 'MB' ) AS index_length_MB FROM information_schema.TABLES;
标签:1024,MB,index,占用,库与表,length,MySQL,table,data From: https://www.cnblogs.com/syw20170419/p/17325698.html