Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display PostgreSQL System variables

I am looking for a bash utility such as mysqladmin that could list all system variables values on the Postgres running instance.

Is there an utility that could be used as mysqladmin : mysqladmin -pxxxxx variables?

like image 867
renard Avatar asked Oct 14 '14 10:10

renard


People also ask

How do I view PostgreSQL conf?

PostgreSQL configuration files are stored in the /etc/postgresql/<version>/main directory. For example, if you install PostgreSQL 12, the configuration files are stored in the /etc/postgresql/12/main directory. To configure IDENT authentication, add entries to the /etc/postgresql/12/main/pg_ident. conf file.

Do we need to set environment variables for PostgreSQL?

For example, if the database server machine is a remote machine, you will need to set the PGHOST environment variable to the name of the database server machine. The environment variable PGPORT may also have to be set.

Are there variables in PostgreSQL?

In PostgreSQL, a variable is a meaningful name for a memory location. A variable holds a value that can be changed through the block or function. A variable is always associated with a particular data type. Before using a variable, you must declare it in the declaration section of the PostgreSQL Block.


1 Answers

Like, say:

psql -qAtc 'select * from pg_settings';

?

or, if you just want key/value:

psql -qAtc 'SELECT name, setting FROM pg_settings';

?

Note that these will show settings as they apply to the current user running the command. So if there are ALTER DATABASE ... SET ... or ALTER USER ... SET ... options in effect you'll see those values, not the underlying ones from postgresql.conf.

For more details on formatting and control over output, see man psql.

If you want human-readable output rather than machine-friendly output, use psql -qc, leaving out the -At (meaning "unaligned, tuples-only").

like image 119
Craig Ringer Avatar answered Jan 04 '23 03:01

Craig Ringer