在MySQL中查找表的大小

sql
阅读 36 收藏 0 点赞 0 评论 0

table_size.sql
-- https://stackoverflow.com/a/9620273/31493

-- Show the size of a single table:
SELECT 
    table_name AS `Table`, 
    round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
WHERE table_schema = "$DB_NAME"
    AND table_name = "$TABLE_NAME";

-- List the size of every table in every database, largest first:
SELECT 
     table_schema as `Database`, 
     table_name AS `Table`, 
     round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
ORDER BY (data_length + index_length) DESC;
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号