Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Como você descobre o tamanho total dos dados no banco de dados MySQL?


Este link tem uma consulta bastante intensa... que lhe dará mais do que você precisa...:
SELECT s.schema_name, 
CONCAT(IFNULL(ROUND((SUM(t.data_length)+SUM(t.index_length)) /1024/1024,2),0.00)) total_size_in_MB, 
CONCAT(IFNULL(ROUND(((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))/1024/1024,2),0.00)) data_used_IN_MB, 
CONCAT(IFNULL(ROUND(SUM(data_free)/1024/1024,2),0.00)) data_free_IN_MB, 
IFNULL(ROUND((((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))/((SUM(t.data_length)+SUM(t.index_length)))*100),2),0) pct_used, 
COUNT(table_name) total_tables 
FROM INFORMATION_SCHEMA.SCHEMATA s 
LEFT JOIN INFORMATION_SCHEMA.TABLES t ON s.schema_name = t.table_schema 
WHERE s.schema_name = 'abc' -- give your schema name 
GROUP BY s.schema_name 
ORDER BY pct_used DESC;