1、服务器版本号 select version();在PGDATA目录下cat PG_Version
2、服务器运行时间:
select date_trunc('second',current_timestamp - pg_postmaster_start_time()) as server_duration;
psql -l ; \l; select datname from pg_database;
psql -c "\d";\d;select count(*) FROM information_schema.tablesWHERE table_schema NOT IN ('information_schema','pg_catalog')
5、列出数据库使用多少空间:
select sum(pg_database_size(datname)) from pg_database;
6、列出表使用多少空间:
select pg_relation_size(relationName): (pg_total_relation_size(),包括索引等空间) ; \dt+ relationName
7、最大的十个表;
SELECT table_name,pg_relation_size(table_name) as sizeFROM information_schema.tablesWHERE table_schema NOT IN ('information_schema','pg_catalog')
ORDER BY size DESC
LIMIT 10;
8、表中有多少行记录:
select count(*) from relationName;