LMLPHP后院

MySQL数据库表空间大小查询SQL技术

maybe yes 发表于 2016-06-08 16:11

使用命令查看 MySQL 的各种信息,大都数都在 information_schema 表里面。

MySQL 数据库表空间大小情况查询 SQL 语句

SELECT 
CONCAT(ROUND(SUM(data_length/1024/1024),2), 'MB') as data_length,
CONCAT(ROUND(SUM(index_length/1024/1024),2), 'MB') as index_length
FROM information_schema.tables
WHERE
table_schema = 'lmlphp'
AND table_name = 'lmlphp_table';

下面的更实用

SELECT 
table_name, 
CONCAT(ROUND(SUM(data_length/1024/1024),2), 'MB') as data_length, 
CONCAT(ROUND(SUM(index_length/1024/1024),2), 'MB') as index_length 
FROM information_schema.tables 
WHERE table_schema = 'lmlphp' 
GROUP BY table_name 
ORDER BY data_length DESC;
相关文章
2024-12-22 14:59:15 1734850755 0.010906