View mysql database size and index size

Suppose you want to check the database name is " xxxx_mall "

1, check the database data footprint size

select concat(round(sum(DATA_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES where table_schema='xxxx_mall'
 
2. Check the size of the database indexes occupancy
 
select concat(round(sum(INDEX_LENGTH/1024/1024),2),'MB') as data from information_schema.TABLES where table_schema='xxxx_mall'
 
3, view the database each table the number of rows, the index size, data size
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'

Guess you like

Origin www.cnblogs.com/xuzhujack/p/12450574.html