Mysql查询数据库表大小
程序员文章站
2024-03-21 14:36:46
...
查询数据库及索引大小
select concat(round(sum(DATA_LENGTH/1024/1024),3),"MB") as data_size, concat(round(sum(MAX_DATA_LENGTH/1024/1024),3),"MB") as max_data_size,concat(round(sum(INDEX_LENGTH/1024/1024),3),"MB") as index_size,concat(round(sum(DATA_FREE/1024/1024),3),"MB") as data_free from tables where table_schema="yxq";
查询指定数据库各表所占内存
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH,TABLE_ROWS,concat(round((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2), 'MB') as data
FROM information_schema.tables WHERE TABLE_SCHEMA='yxq' ORDER BY DATA_LENGTH+INDEX_LENGTH desc;