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;
2、查看单个库:
select concat(truncate(sum(data_length)/1024/1024,2),'MB') as data_size,
concat(truncate(sum(max_data_length)/1024/1024,2),'MB') as max_data_size,
concat(truncate(sum(data_free)/1024/1024,2),'MB') as data_free,
concat(truncate(sum(index_length)/1024/1024,2),'MB') as index_size
from information_schema.tables where TABLE_SCHEMA ='databasename';
3、查看单库下所有表:
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 = 'databasename' group by TABLE_NAME order by data_length desc;
4、查看单库下单表:
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS FROM TABLES
WHERE TABLE_SCHEMA='数据库名' AND TABLE_NAME='表名'
评论区