时间:2021-07-01 10:21:17 帮助过:26人阅读
1、查询数据库版本
- <code> select version();
- </code>
2、查询数据库的运行时间
- <code> select current_timestamp-pg_postmaster_start_time() as uptime;
- </code>
3、查询数据库的数据量
SELECT
- <code>datname ,
- a.rolname ,
- pg_encoding_to_char(encoding) ,
- datcollate ,
- datctype ,
- pg_size_pretty(pg_database_size(datname))
- </code>
FROM
- <code>pg_database d ,
- pg_authid a
- </code>
WHERE
- <code>d.datdba = a.oid
- AND datname NOT IN (\‘template0\‘ ,\‘template1\‘ ,\‘postgres\‘ )
- </code>
ORDER BY
- <code>pg_database_size(datname) DESC;
- </code>
4、 查询手游数据库连接数使用情况
SELECT
- <code> s.setting \"可用连接数\" ,
- a.used_session \"已使用连接数\" ,
- s.setting::bigintwww.diuxie.com - a.used_session \"剩余连接数\"
- </code>
FROM
- <code> pg_settings s,
- (
- SELECT
- COUNT(*) AS used_session
- FROM
- pg_stat_activity) a
- </code>
WHERE
- <code> s.name=\‘max_connections\‘;
- </code>
5、查询数据库参数配置
- <code> select name,setting,unit from pg_settings;
- </code>
6、查询当前数据库
- <code> select current_database();</code>
如何查询postgresql数量?
标签:time() esc dba ast enc 运行时 uptime post sele