Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/ref/dropdb.sgml`
76f8af0dc6dff9c731262471912840d6f924064d09bdbf300000000100000bf3
 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>

    <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-dropdatabase"/>
   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 destroy the database <literal>demo</literal> on the default
    database server:
<screen>
<prompt>$ </prompt><userinput>dropdb demo</userinput>
</screen>
   </para>

   <para>
    To destroy the database <literal>demo</literal> using the
    server on host <literal>eden</literal>, port 5000, with verification and a peek
    at the underlying command:
<screen>
<prompt>$ </prompt><userinput>dropdb -p 5000 -h eden -i -e demo</userinput>
<computeroutput>Database "demo" will be permanently deleted.
Are you sure? (y/n) </computeroutput><userinput>y</userinput>
<computeroutput>DROP DATABASE demo;</computeroutput>
</screen></para>
 </refsect1>


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

  <simplelist type="inline">
   <member><xref linkend="app-createdb"/></member>
   <member><xref linkend="sql-dropdatabase"/></member>
  </simplelist>
 </refsect1>

</refentry>

Title: dropdb: Environment, Diagnostics, Examples, and See Also
Summary
This section covers the environment variables used by `dropdb`, including `PGHOST`, `PGPORT`, `PGUSER`, and `PG_COLOR`, as well as those supported by `libpq`. It also provides diagnostic information, references to related documentation, and examples of how to use `dropdb` to remove a database. Finally, it lists related commands like `createdb` and the SQL command `DROP DATABASE`.