Skip to content

Instantly share code, notes, and snippets.

@morkot
Last active August 29, 2015 14:12
Show Gist options
  • Save morkot/72db3fabcbba36f755df to your computer and use it in GitHub Desktop.
Save morkot/72db3fabcbba36f755df to your computer and use it in GitHub Desktop.
Calculate number of rows in all MySQL databases with total sum (rough)
SELECT IFNULL(TABLE_SCHEMA, 'total') as table_schema, SUM(TABLE_ROWS) as element_count
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA IN (SELECT schema_name FROM information_schema.schemata)
GROUP BY TABLE_SCHEMA WITH ROLLUP;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment