Monday , December 23 2024

Postgresql change configuration parameters

This article contains information about change postgresql configuration in postgresql. If you find to learn more about postgresql.conf file you should read below articles.

postgresql.conf settings in PostgreSQL

Postgresql change configuration parameters

We can change postgresql.conf parameter directy from postgresql.conf file or we can change same settings from postgresql.auto.conf file via ALTER system command.

Change postgresql.auto.conf file parameters via SQL

PostgreSQL provides three SQL commands for changing parameters.

Change postgresql configuration by using ALTER SYSTEM

Used to change cluster-level parameters, equivalent to editing postgresql.conf. We said that the changes made with this parameter are written to the postgresql.auto.conf file.

Examples;

Change postgresql configuration by using ALTER DATABASE

Global parameters are overridden on a database basis.

Examples;

Change postgresql configuration by using ALTER ROLE

It allows passing user-specific parameters.

Examples;

The values set with ALTER DATABASE and ALTER ROLE are applied only when starting the new database session. They override values obtained from configuration files or the server command line and set defaults for the remainder of the session. Each parameter cannot be applied on database and session basis. Therefore, ALTER DATABASE and ALTER ROLE commands cannot be used for some parameters.

 

When a client connects to the database, PostgreSQL provides two additional SQL commands (and equivalent function) to interact with session-local configuration settings:

SHOW command allows viewing the current value of all parameters. The corresponding function is current_setting.

SET command allows to change the current value of parameters that can be set locally to a session; It has no effect on other sessions. The corresponding function is set_config.

 

Loading

About Mustafa Bektaş Tepe

Leave a Reply

Your email address will not be published. Required fields are marked *