mysql get table size – 2 ways to Get the Size of a Table in MySQL

mysql get table size : To get MySQL table size of all tables in a database use: SELECT TABLE_NAME AS `Table`, ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)` FROM information_schema.

mysql get table size

We will use the information_schema table to find tables and databases size. Check Single Database Size in MySQL.

How to Check MySQL Database & Tables Size?

Size of a specific 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';

2. Size of all tables, descending order:

SELECT
	table_schema AS `Pakainfo_v1`,
	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;

Don’t Miss : how to retrieve data from database in html form

Read Also:  php redirect new tab/window

Check Single Database Size in MySQL

SELECT table_schema "Pakainfo_v1", SUM( data_length + index_length)/1024/1024
"Database Size (MB)" FROM information_schema.TABLES where table_schema = 'Pakainfo_v1';

Check ALL Databases Size in MySQL

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

Check Single Table Size in MySQL Database

SELECT table_name "Table Name", table_rows "Rows Count", round(((data_length + index_length)/1024/1024),2)
"Table Size (MB)" FROM information_schema.TABLES WHERE table_schema = "Pakainfo_v1" AND table_name ="table_one";

Check All Table Size in MySQL Database

SELECT table_name "Table Name", table_rows "Rows Count", round(((data_length + index_length)/1024/1024),2)
"Table Size (MB)" FROM information_schema.TABLES WHERE table_schema = "Pakainfo_v1";

List All Table Sizes From ALL Databases

SELECT
  TABLE_SCHEMA AS `Database`,
  TABLE_NAME AS `Table`,
  ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
  information_schema.TABLES
ORDER BY
  (DATA_LENGTH + INDEX_LENGTH)
DESC;


I hope you get an idea about mysql get table size.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.