1.查看当前数据库实例的版本信息
postgres=# select version(); version --------------------------------------------------------------------------------------------------------- PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit (1 row)
2.查看数据库的启动时间
postgres=# select pg_postmaster_start_time(); pg_postmaster_start_time ------------------------------- 2023-12-16 09:52:59.531553+08 (1 row)
3.查看最后load配置时间
postgres=# select pg_conf_load_time(); pg_conf_load_time ------------------------------- 2023-12-16 09:54:44.140466+08 (1 row)
4.查看当前数据库时区
postgres=# show timezone; TimeZone --------------- Asia/Shanghai (1 row)
5.查看当前时间
postgres=# select now(); now ----------------------------- 2023-12-18 21:55:17.3275+08 (
6.查看当前数据库服务器的ip地址和端口
postgres=# select inet_server_addr(),inet_server_port(); inet_server_addr | inet_server_port ------------------+------------------ | (1 row)
7.查询当前session的后台服务器进程的PID
postgres=# select pg_backend_pid(); pg_backend_pid ---------------- 3449 (1 row
8.查看当前参数配置情况
postgres=# show shared_buffers; shared_buffers ---------------- 128MB
9.修改当前session的参数配置
postgres=# set maintenance_work_mem to '128MB'; SET
11.查看数据库大小
postgres=# select pg_database_size('postgres'),pg_size_pretty(pg_database_size('postgres')); pg_database_size | pg_size_pretty ------------------+---------------- 8758051 | 8553 kB
标签:size,postgres,查看,pg,常用命令,row,select,PG From: https://www.cnblogs.com/zmc60/p/17912511.html