I’m going on writing primitive posts about the fascinating world of relational database management systems. :)
MySQL, size of all databases:
mysql> SELECT table_schema \
"Database name", \
sum( data_length + index_length ) / 1024 / 1024 \
"Data Base Size in MB" FROM \
information_schema.TABLES GROUP BY table_schema;
+--------------------+----------------------+
| Database name | Data Base Size in MB |
+--------------------+----------------------+
| fluxbb | 0.04585648 |
| information_schema | 0.00781250 |
| mysql | 0.60614872 |
| wordpress | 2.22493362 |
+--------------------+----------------------+
4 rows in set (0.13 sec)
PostgreSQL, size of all databases:
cdr=> SELECT pg_database.datname,pg_size_pretty(pg_database_size(pg_database.datname)) \
AS size FROM pg_database;
datname | size
-----------+---------
template1 | 6705 kB
template0 | 6697 kB
postgres | 6820 kB
cdr | 28 GB
Size of ‘acme_cdr’ table:
cdr=> SELECT pg_size_pretty(pg_total_relation_size('acme_cdr'));
pg_size_pretty
----------------
28 GB
Tags: mysql, postgresql, sql