Home Explore Blog Models CI



postgresql

78th chunk of `doc/src/sgml/ref/psql-ref.sgml`
d1a6edc1cafcdf5058d1aeb7872455d1324966d4e02286d10000000100000fa0
 id="app-psql-environment-psqlrc">
    <term><envar>PSQLRC</envar></term>

    <listitem>
     <para>
      Alternative location of the user's <filename>.psqlrc</filename> file. Tilde (<literal>~</literal>) expansion is performed.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="app-psql-environment-shell">
    <term><envar>SHELL</envar></term>

    <listitem>
     <para>
      Command executed by the <command>\!</command> command.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="app-psql-environment-tmpdir">
    <term><envar>TMPDIR</envar></term>

    <listitem>
     <para>
      Directory for storing temporary files.  The default is
      <filename>/tmp</filename>.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>

  <para>
   This utility, like most other <productname>PostgreSQL</productname> utilities,
   also uses the environment variables supported by <application>libpq</application>
   (see <xref linkend="libpq-envars"/>).
  </para>

 </refsect1>


 <refsect1>
  <title>Files</title>

 <variablelist>
  <varlistentry id="app-psql-files-psqlrc">
   <term><filename>psqlrc</filename> and <filename>~/.psqlrc</filename></term>
   <listitem>
    <para>
     Unless it is passed an <option>-X</option> option,
     <application>psql</application> attempts to read and execute commands
     from the system-wide startup file (<filename>psqlrc</filename>) and then
     the user's personal startup file (<filename>~/.psqlrc</filename>), after
     connecting to the database but before accepting normal commands.
     These files can be used to set up the client and/or the server to taste,
     typically with <command>\set</command> and <command>SET</command>
     commands.
    </para>
    <para>
     The system-wide startup file is named <filename>psqlrc</filename>.
     By default it is
     sought in the installation's <quote>system configuration</quote> directory,
     which is most reliably identified by running <literal>pg_config
     --sysconfdir</literal>.
     Typically this directory will be <filename>../etc/</filename>
     relative to the directory containing
     the <productname>PostgreSQL</productname> executables.
     The directory to look in can be set explicitly via
     the <envar>PGSYSCONFDIR</envar> environment variable.
    </para>
    <para>
     The user's personal startup file is named <filename>.psqlrc</filename>
     and is sought in the invoking user's home directory.
     On Windows the personal startup file is instead named
     <filename>%APPDATA%\postgresql\psqlrc.conf</filename>.
     In either case, this default file path can be overridden by setting
     the <envar>PSQLRC</envar> environment variable.
    </para>
    <para>
     Both the system-wide startup file and the user's personal startup file
     can be made <application>psql</application>-version-specific
     by appending a dash and the <productname>PostgreSQL</productname>
     major or minor release identifier to the file name,
     for example <filename>~/.psqlrc-&majorversion;</filename> or
     <filename>~/.psqlrc-&version;</filename>.
     The most specific version-matching file will be read in preference
     to a non-version-specific file.
     These version suffixes are added after determining the file path
     as explained above.
    </para>
   </listitem>
  </varlistentry>

  <varlistentry id="app-psql-files-psql-history">
   <term><filename>.psql_history</filename></term>
   <listitem>
    <para>
     The command-line history is stored in the file
     <filename>~/.psql_history</filename>, or
     <filename>%APPDATA%\postgresql\psql_history</filename> on Windows.
    </para>
    <para>
     The location of the history file can be set explicitly via
     the <varname>HISTFILE</varname> <application>psql</application> variable or
     the <envar>PSQL_HISTORY</envar> environment variable.
    </para>
   </listitem>
  </varlistentry>
 </variablelist>
 </refsect1>


 <refsect1>
 

Title: psql Environment Variables and Files
Summary
This section describes more psql environment variables: PSQLRC (location of the user's .psqlrc file), SHELL (command executed by the \! command), and TMPDIR (directory for storing temporary files). It also covers files used by psql: psqlrc (~/.psqlrc) (system-wide and user startup files containing psql commands executed upon connection) and .psql_history (~/.psql_history) (stores command-line history).