共计 653 个字符,预计需要花费 2 分钟才能阅读完成。
1、查询数据库版本
select version();
2、查询数据库的运行工夫
select current_timestamp-pg_postmaster_start_time() as uptime;
3、查询数据库的数据量
SELECT
datname ,
a.rolname ,
pg_encoding_to_char(encoding) ,
datcollate ,
datctype ,
pg_size_pretty(pg_database_size(datname))
FROM
pg_database d ,
pg_authid a
WHERE
d.datdba = a.oid
AND datname NOT IN ('template0' ,'template1' ,'postgres')
ORDER BY
pg_database_size(datname) DESC;
4、查问手游数据库连接数应用状况
SELECT
s.setting "可用连接数" ,
a.used_session "已应用连接数" ,
s.setting::bigintwww.diuxie.com - a.used_session "残余连接数"
FROM
pg_settings s,
(
SELECT
COUNT(*) AS used_session
FROM
pg_stat_activity) a
WHERE
s.name='max_connections';
5、查询数据库参数配置
select name,setting,unit from pg_settings;
6、查问以后数据库
select current_database();
正文完