Difference between revisions of "Useful MySQL Commands"
From KOP KB
(Created page with "This is an article dedicated to useful SQL commands to run in PHPmyAdmin or via Heidi/SQLYog. They serve various purposes and hopefully come in handy. == Display Table Names...") |
(No difference)
|
Revision as of 16:34, 1 November 2016
This is an article dedicated to useful SQL commands to run in PHPmyAdmin or via Heidi/SQLYog. They serve various purposes and hopefully come in handy.
Display Table Names Sorted by Size
Remember to replace DATABASENAME with the name of the database. this will return a list of all tables in the database sorted from largest use to smallest in MB.
SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "DATABASENAME" ORDER BY (data_length + index_length) DESC;