Skip to content

Instantly share code, notes, and snippets.

@runningnet
Created March 9, 2017 11:31
Show Gist options
  • Save runningnet/5510cba1d1646b15c3c1a0db442e1b18 to your computer and use it in GitHub Desktop.
Save runningnet/5510cba1d1646b15c3c1a0db442e1b18 to your computer and use it in GitHub Desktop.
Datenbank und Tabellen Größen in SQL anzeigen
SELECT
table_schema AS 'Datenbankname',
Round( SUM( data_length ) / 1024 / 1024, 3 ) AS 'Daten (MB)',
Round( SUM( index_length ) / 1024 / 1024, 3 ) AS 'Index (MB)',
Round( Sum( data_length + index_length ) / 1024 / 1024, 3 ) AS 'Gesamt (MB)',
Round( Sum( data_free ) / 1024 / 1024, 3 ) AS 'Freier Speicher (MB)'
FROM information_schema.tables
GROUP BY table_schema ;
SELECT
TABLE_NAME AS `Table`,
ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
information_schema.TABLES
WHERE
TABLE_SCHEMA = "TABELENNAMMENEINTRAGEN"
ORDER BY
(DATA_LENGTH + INDEX_LENGTH)
DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment