mysql查看數據庫大小、索引大小與表數量


假定要查的數據庫名稱是“xxxx_mall

1、查看數據庫數據占用大小

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES where table_schema='xxxx_mall'
 
2、查看數據庫索引占用大小
 
select concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES where table_schema='xxxx_mall'
 
3、查看數據庫各個表的行數,索引大小,數據大小
select table_name,table_rows,concat(round((index_length)/1024/1024,2),'MB') index_data ,concat(round((data_length)/1024/1024,2),'MB') data_data
from information_schema.TABLES where table_schema='xxxx_mall'
 
4、查看各個數據庫的表個數
select count(*) tables, table_schema from information_schema.tables group by table_schema



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM