Show the total database size
Oracle
SELECT ROUND(SUM(bytes)/1024/1024/1024, 2) AS total_gb
FROM dba_data_files;For used segments only, sum dba_segments. Add dba_temp_files for TEMP.
PostgreSQL
SELECT pg_size_pretty(pg_database_size(current_database()));For all databases: SELECT datname, pg_size_pretty(pg_database_size(datname)) FROM pg_database ORDER BY 2 DESC;
MySQL
SELECT table_schema AS db,
ROUND(SUM(data_length + index_length)/1024/1024, 1) AS mb
FROM information_schema.tables
GROUP BY table_schema
ORDER BY mb DESC;For InnoDB this value is an estimate; for the exact file size check ibdata/the files at the OS level.
SQL Server
EXEC sp_spaceused;
-- All databases:
SELECT DB_NAME(database_id) AS db,
CAST(SUM(size) * 8.0 / 1024 AS DECIMAL(10,1)) AS mb
FROM sys.master_files
GROUP BY database_id;The size column is in 8 KB pages; * 8 / 1024 converts it to MB.
MongoDB
db.stats(1024*1024)
// returns the dataSize, storageSize, indexSize fields in MBstorageSize is the compressed on-disk size; dataSize is the uncompressed logical size.
Redis
INFO memory
# the used_memory_human line gives the total size in memory
DBSIZE # number of keysRedis is memory-based; 'size' means RAM usage. The RDB/AOF file size is the persisted state on disk.