-
-
Save cmlenz/1992369 to your computer and use it in GitHub Desktop.
Database Sizes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- PostgreSql | |
SELECT | |
pg_database.datname AS "Database Name", | |
pg_database_size(pg_database.datname) / 1024.0 / 1024.0 AS "Database Size (MB)" | |
FROM pg_database; | |
-- MySql | |
SELECT | |
table_schema "Database Name", | |
sum( data_length + index_length ) / 1024 / 1024 "Database Size (MB)" | |
FROM information_schema.TABLES | |
GROUP BY table_schema; | |
-- MSSQL (current database only) | |
EXEC sp_spaceused | |
-- WARNING: returns 2(!) result sets, and the size values | |
-- are strings (!!) such as "517.13 MB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment