简体   繁体   中英

memory size of database and tables

I am new to the MySQL learning. I have a database that consist of 34 tables. I just want to know the memory size of database and each tables. Is there any special query or script to finding the memory size? please help me out with this. am using InnoDB engine.

For DB

 SELECT table_schema AS "Database", 
 ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" 
 FROM information_schema.TABLES 
 GROUP BY table_schema;

For table

SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
WHERE table_schema = "database_name"
ORDER BY (data_length + index_length) DESC;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM