-- =================================================

-- Postgresql

-- DB size
-- select pg_database_size('DBname') --,单位:bigint
-- select pg_size_pretty(pg_database_size('DBname')); --单位:MB -- "4677 MB"

-- pg_tablespace
-- select spcname from pg_tablespace;
-- select pg_tablespace_size('pg_default'); ,单位:bigint
-- select pg_size_pretty(pg_tablespace_size('pg_default')); --单位:MB -- "9418 MB"

-- all table size : 从大到小排序列出
-- select relname, pg_size_pretty(pg_relation_size(relid))
from pg_stat_user_tables
where schemaname='public' order by pg_relation_size(relid) desc;

-- all table count :按记录数量从大到小排序列出
-- SELECT relname, reltuples
FROM pg_class r JOIN pg_namespace n ON (relnamespace = n.oid)
WHERE relkind = 'r' AND n.nspname = 'public' ORDER BY reltuples desc
-- =====================================================

 

其他数据库陆续添加中。