Ir al contenido


Foto

[TRUCO MySQL] Encuentre el tamaño de todas las bases de datos en el servidor.


  • Por favor identifícate para responder
No hay respuestas en este tema

#1 sir.dev.a.lot

sir.dev.a.lot

    Advanced Member

  • Miembros
  • PipPipPip
  • 545 mensajes
  • Location127.0.0.1

Escrito 19 diciembre 2016 - 11:30

[TRUCO MySQL] Encuentre el tamaño de todas las bases de datos en el servidor.


sql
  1. DROP VIEW IF EXISTS dbsize;
  2. CREATE VIEW dbsize AS
  3. SELECT
  4. s.schema_name AS 'Schema',
  5. SUM(t.data_length) AS DATA,
  6. SUM( t.index_length ) AS Indexes,
  7. SUM(t.data_length) + SUM(t.index_length) AS 'Usado en Mb',
  8. IF(SUM(t.data_free)=0,'',SUM(t.data_free)) AS 'Libre en Mb',
  9. IF( SUM(t.data_free)=0,
  10. '',
  11. 100 * (SUM(t.data_length) + SUM(t.index_length)) / ((SUM(t.data_length)+SUM(t.index_length) + SUM(IFNULL(t.data_free,0))) )
  12. ) AS '% Usado',
  13. COUNT(TABLE_NAME) AS TABLES
  14. FROM information_schema.schemata s
  15. LEFT JOIN information_schema.TABLES t ON s.schema_name = t.table_schema
  16. GROUP BY s.schema_name
  17. WITH ROLLUP

Saludos!


  • 1




IP.Board spam blocked by CleanTalk.