Skip to content

Instantly share code, notes, and snippets.

@cesarmiquel
Last active December 6, 2019 17:57
Show Gist options
  • Save cesarmiquel/71b0af02f814e677cefc to your computer and use it in GitHub Desktop.
Save cesarmiquel/71b0af02f814e677cefc to your computer and use it in GitHub Desktop.
Show all tables (and their row count) for tables with more than 10000 rows for MySQL. Taken from: http://stackoverflow.com/questions/286039/get-record-counts-for-all-tables-in-mysql-database. The second version from here: https://www.lullabot.com/articles/importing-huge-databases-faster
SELECT table_name, table_rows, data_length, index_length,
round(((data_length + index_length) / 1024 / 1024),2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "drupal"
ORDER BY round(((data_length + index_length) / 1024 / 1024),2) DESC
LIMIT 0,30;
SELECT table_name, table_rows
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'drupal'
AND table_rows > 10000
ORDER BY table_rows desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment