Skip to content

Instantly share code, notes, and snippets.

View amansrivastava's full-sized avatar
🏠
Working from home

Aman Srivastava amansrivastava

🏠
Working from home
View GitHub Profile
@anujkaushal
anujkaushal / database-and-table-size.sql
Last active December 9, 2022 12:01
SQL Query to get database & table size in MB/GB
SELECT
'Total size in mysql' as `DB / Table Name`,
SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024),2)) AS `SizeInMB`,
SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 / 1024),2)) AS `SizeInGB`
FROM
information_schema.TABLES
UNION
SELECT