Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/ref/reindexdb.sgml`
fd5d12cac7fdeb73cec8450cb7bcd15c137948dc9068e0150000000100000da6
 Force <application>reindexdb</application> to prompt for a
        password before connecting to a database.
       </para>

       <para>
        This option is never essential, since
        <application>reindexdb</application> will automatically prompt
        for a password if the server demands password authentication.
        However, <application>reindexdb</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 reindex.
        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-reindex"/>
   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 reindex the database <literal>test</literal>:
<screen>
<prompt>$ </prompt><userinput>reindexdb test</userinput>
</screen>
   </para>

   <para>
    To reindex the table <literal>foo</literal> and the index
    <literal>bar</literal> in a database named <literal>abcd</literal>:
<screen>
<prompt>$ </prompt><userinput>reindexdb --table=foo --index=bar abcd</userinput>
</screen></para>

 </refsect1>

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

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

</refentry>

Title: reindexdb: Maintenance Database, Environment Variables, Diagnostics, and Examples
Summary
This section details the --maintenance-db option for reindexdb when used with -a/--all, which allows specifying the database used to gather the list of databases to reindex. It also covers relevant environment variables such as PGDATABASE, PGHOST, PGPORT, PGUSER, and PG_COLOR. The section further provides guidance on diagnostics and potential problems, referencing documentation on SQL REINDEX and psql. Finally, it presents practical examples of using reindexdb to reindex a database and specific tables/indexes.