Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/dropdb.sgml`
b600f08af5c1bef02802f95547a9a503eda0f89cefb6b5720000000100000810
 the server requires
        password authentication and a password is not available by
        other means such as a <filename>.pgpass</filename> file, the
        connection attempt will fail.  This option can be useful in
        batch jobs and scripts where no user is present to enter a
        password.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-W</option></term>
      <term><option>--password</option></term>
      <listitem>
       <para>
        Force <application>dropdb</application> to prompt for a
        password before connecting to a database.
       </para>

       <para>
        This option is never essential, since
        <application>dropdb</application> will automatically prompt
        for a password if the server demands password authentication.
        However, <application>dropdb</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>
         Specifies the name of the database to connect to in order to drop the
         target database. If not specified, the <literal>postgres</literal>
         database will be used; if that does not exist (or is the database
         being dropped), <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.
       </para>
      </listitem>
     </varlistentry>
   </variablelist>
  </para>
 </refsect1>


 <refsect1>
  <title>Environment</title>

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

Title: dropdb: Password Options and Maintenance Database
Summary
The `dropdb` command-line options include `-w` or `--no-password` to prevent password prompts and `-W` or `--password` to force a password prompt. The `--maintenance-db` option specifies the database to connect to for dropping the target database, defaulting to `postgres` or `template1` if necessary. The section also introduces the environment variables that can be used to configure the connection.