Estimated MySQL Table Row Count

Ever wanted a quick summary of how many rows are in all of the tables in a MySQL/MariaDB database?

This query will provide that for you. If you’re using the InnoDB storage engine, it’s an estimate; if you’re using MyISAM, then it should be accurate.

SELECT table_schema AS `Database`,
table_name AS `Table`, 
FORMAT(table_rows, 0) AS `Rows`  
FROM information_schema.tables 
-- WHERE table_schema = 'database_name'
ORDER BY table_rows DESC;

MySQL Table Size

Ever wondered which database or tables are taking up disk space on a MySQL/MariaDB server?

This query will provide the size of each table:

SELECT TABLE_SCHEMA AS `Database`,
TABLE_NAME AS `Table`,
FORMAT(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS `Size (MB)`,
FORMAT((data_free / 1024 / 1024), 2) AS `Reclaimable Size (MB)`
FROM information_schema.TABLES
-- WHERE `TABLE_SCHEMA` = 'database_name'
ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC;