Skip to main content
Active reading [<https://english.stackexchange.com/questions/4645/is-it-ever-correct-to-have-a-space-before-a-question-or-exclamation#comment206109_4645>].
Source Link
Peter Mortensen
  • 31.1k
  • 22
  • 111
  • 134

If you want the list of all database sizes sorted, you can use  :

SELECT * 
FROM   (SELECT table_schema AS `DB Name`, 
           ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS `DB Size in MB`
        FROM   information_schema.tables 
        GROUP  BY `DB Name`) AS tmp_table 
ORDER  BY `DB Size in MB` DESC; 

If you want the list of all database sizes sorted, you can use  :

SELECT * 
FROM   (SELECT table_schema AS `DB Name`, 
           ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS `DB Size in MB`
        FROM   information_schema.tables 
        GROUP  BY `DB Name`) AS tmp_table 
ORDER  BY `DB Size in MB` DESC; 

If you want the list of all database sizes sorted, you can use:

SELECT * 
FROM   (SELECT table_schema AS `DB Name`, 
           ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS `DB Size in MB`
        FROM   information_schema.tables 
        GROUP  BY `DB Name`) AS tmp_table 
ORDER  BY `DB Size in MB` DESC; 
added 8 characters in body
Source Link

If you want the list of all database sizes sorted, you can use :

SELECT `DB Name`, `DB Size in MB`* 
FROM   (SELECT table_schema                AS `DB Name`, 
           SumROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS `DB Size in MB` 
        FROM   information_schema.tables 
        GROUP  BY `DB Name`) AS tmp_table 
ORDER  BY `DB Size in MB` DESC; 

If you want the list of all database sizes sorted, you can use :

SELECT `DB Name`, `DB Size in MB` 
FROM   (SELECT table_schema                AS `DB Name`, 
           Sum(data_length + index_length) AS `DB Size in MB` 
        FROM   information_schema.tables 
        GROUP  BY `DB Name`) AS tmp_table 
ORDER  BY `DB Size in MB` DESC; 

If you want the list of all database sizes sorted, you can use :

SELECT * 
FROM   (SELECT table_schema AS `DB Name`, 
           ROUND(SUM(data_length + index_length) / 1024 / 1024, 1) AS `DB Size in MB`
        FROM   information_schema.tables 
        GROUP  BY `DB Name`) AS tmp_table 
ORDER  BY `DB Size in MB` DESC; 
Source Link

If you want the list of all database sizes sorted, you can use :

SELECT `DB Name`, `DB Size in MB` 
FROM   (SELECT table_schema                AS `DB Name`, 
           Sum(data_length + index_length) AS `DB Size in MB` 
        FROM   information_schema.tables 
        GROUP  BY `DB Name`) AS tmp_table 
ORDER  BY `DB Size in MB` DESC;