How do I query the size of data in a table in MySQL?

You can use the following MySQL statement to query the size of data in a table:

SELECT table_name AS "表名", 
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "数据大小(MB)"
FROM information_schema.tables
WHERE table_schema = 'your_database_name'
AND table_name = 'your_table_name';

Replace “your_database_name” with the name of your database, and “your_table_name” with the name of your table in the statement above. After executing this statement, you will get the size of the data for that table in megabytes.

bannerAds