0

MySQL 怎样查询所有表大小,按大小排序

eden created at5 years ago view count: 2912

数据库的服务器磁盘快满了。 想对大的表数据进行清理下, 需要先对表按大小排序下。

report
回复
0
SELECT 
     table_schema as `Database`, 
     table_name AS `Table`, 
     round(((data_length + index_length) / 1024 / 1024), 2) `大小 (MB)` 
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) DESC;
5 years ago 回复
0
neo #
when in doubt, use brute force

查询所有数据库大小SQL

SELECT table_schema  "DB Name", 
   Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" 
FROM   information_schema.tables 
GROUP  BY table_schema; 
5 years ago 回复