Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/ref/clusterdb.sgml`
4742495f691dce90b4fc62562a1791027fb29f79e492d1650000000100000d35
 before connecting to a database.
       </para>

       <para>
        This option is never essential, since
        <application>clusterdb</application> will automatically prompt
        for a password if the server demands password authentication.
        However, <application>clusterdb</application> will waste a
        connection attempt finding out that the server wants a password.
        In some cases it is worth typing <option>-W</option> to avoid the extra
        connection attempt.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--maintenance-db=<replaceable class="parameter">dbname</replaceable></option></term>
      <listitem>
       <para>
        When the <option>-a</option>/<option>--all</option> is used, connect
        to this database to gather the list of databases to cluster.
        If not specified, the <literal>postgres</literal> database will be used,
        or if that does not exist, <literal>template1</literal> will be used.
        This can be a <link linkend="libpq-connstring">connection
        string</link>.  If so, connection string parameters will override any
        conflicting command line options.  Also, connection string parameters
        other than the database name itself will be re-used when connecting
        to other databases.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
 </refsect1>


 <refsect1>
  <title>Environment</title>

  <variablelist>
   <varlistentry>
    <term><envar>PGDATABASE</envar></term>
    <term><envar>PGHOST</envar></term>
    <term><envar>PGPORT</envar></term>
    <term><envar>PGUSER</envar></term>

    <listitem>
     <para>
      Default connection parameters
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><envar>PG_COLOR</envar></term>
    <listitem>
     <para>
      Specifies whether to use color in diagnostic messages. Possible values
      are <literal>always</literal>, <literal>auto</literal> and
      <literal>never</literal>.
     </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>Diagnostics</title>

  <para>
   In case of difficulty, see <xref linkend="sql-cluster"/>
   and <xref linkend="app-psql"/> for
   discussions of potential problems and error messages.
   The database server must be running at the
   targeted host.  Also, any default connection settings and environment
   variables used by the <application>libpq</application> front-end
   library will apply.
  </para>

 </refsect1>


 <refsect1>
  <title>Examples</title>

   <para>
    To cluster the database <literal>test</literal>:
<screen>
<prompt>$ </prompt><userinput>clusterdb test</userinput>
</screen>
   </para>

   <para>
    To cluster a single table
    <literal>foo</literal> in a database named
    <literal>xyzzy</literal>:
<screen>
<prompt>$ </prompt><userinput>clusterdb --table=foo xyzzy</userinput>
</screen></para>

 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-cluster"/></member>
  </simplelist>
 </refsect1>

</refentry>

Title: clusterdb: Environment Variables, Diagnostics, and Examples
Summary
This section covers the environment variables used by `clusterdb` (including those supported by libpq), provides diagnostic information for troubleshooting, and presents practical examples of how to use the `clusterdb` command to cluster databases and tables.