Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/config.sgml`
d2e3b368fde08ce8d36b182cb071adf0a71d62a7ff2023890000000100000fa0
 linkend="view-pg-file-settings"><structname>pg_file_settings</structname></link>
     can be helpful for pre-testing changes to the configuration files, or for
     diagnosing problems if a <systemitem>SIGHUP</systemitem> signal did not have the
     desired effects.
    </para>
   </sect2>

   <sect2 id="config-setting-sql">
    <title>Parameter Interaction via SQL</title>

     <para>
      <productname>PostgreSQL</productname> provides three SQL
      commands to establish configuration defaults.
      The already-mentioned <command>ALTER SYSTEM</command> command
      provides an SQL-accessible means of changing global defaults; it is
      functionally equivalent to editing <filename>postgresql.conf</filename>.
      In addition, there are two commands that allow setting of defaults
      on a per-database or per-role basis:
     </para>

     <itemizedlist>
     <listitem>
      <para>
       The <link linkend="sql-alterdatabase"><command>ALTER DATABASE</command></link> command allows global
       settings to be overridden on a per-database basis.
      </para>
     </listitem>

     <listitem>
      <para>
       The <link linkend="sql-alterrole"><command>ALTER ROLE</command></link> command allows both global and
       per-database settings to be overridden with user-specific values.
      </para>
     </listitem>
    </itemizedlist>

     <para>
      Values set with <command>ALTER DATABASE</command> and <command>ALTER ROLE</command>
      are applied only when starting a fresh database session.  They
      override values obtained from the configuration files or server
      command line, and constitute defaults for the rest of the session.
      Note that some settings cannot be changed after server start, and
      so cannot be set with these commands (or the ones listed below).
    </para>

     <para>
      Once a client is connected to the database, <productname>PostgreSQL</productname>
      provides two additional SQL commands (and equivalent functions) to
      interact with session-local configuration settings:
    </para>

    <itemizedlist>
     <listitem>
     <para>
      The <link linkend="sql-show"><command>SHOW</command></link> command allows inspection of the
      current value of any parameter.  The corresponding SQL function is
      <function>current_setting(setting_name text)</function>
      (see <xref linkend="functions-admin-set"/>).
     </para>
     </listitem>

     <listitem>
      <para>
       The <link linkend="sql-set"><command>SET</command></link> command allows modification of the
       current value of those parameters that can be set locally to a
       session; it has no effect on other sessions.
       Many parameters can be set this way by any user, but some can
       only be set by superusers and users who have been
       granted <literal>SET</literal> privilege on that parameter.
       The corresponding SQL function is
       <function>set_config(setting_name, new_value, is_local)</function>
       (see <xref linkend="functions-admin-set"/>).
      </para>
     </listitem>
    </itemizedlist>

    <para>
     In addition, the system view <link
     linkend="view-pg-settings"><structname>pg_settings</structname></link> can be
     used to view and change session-local values:
    </para>

    <itemizedlist>
     <listitem>
      <para>
       Querying this view is similar to using <command>SHOW ALL</command> but
       provides more detail.  It is also more flexible, since it's possible
       to specify filter conditions or join against other relations.
      </para>
     </listitem>

     <listitem>
      <para>
       Using <command>UPDATE</command> on this view, specifically
       updating the <structname>setting</structname> column, is the equivalent
       of issuing <command>SET</command> commands.  For example, the equivalent of
<programlisting>
SET configuration_parameter TO DEFAULT;
</programlisting>
       is:
<programlisting>
UPDATE pg_settings SET setting =

Title: SQL Commands for Parameter Interaction: ALTER, SHOW, and SET
Summary
This section details the SQL commands used to interact with configuration parameters in PostgreSQL. ALTER DATABASE and ALTER ROLE set defaults at the database or role level, effective at session start. SHOW and SET commands, along with their corresponding functions, allow inspection and modification of session-local parameters. The pg_settings system view provides another way to view and change session-local values, offering more detail and flexibility than SHOW ALL.