Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/pg_dump.sgml`
f1d5c3ef060eecab2069c463d94e1ebceae77c1fba12230a0000000100000fa1
 behavior
        is to output large objects, when data is being dumped, see the
        <option>-b</option> documentation.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-c</option></term>
      <term><option>--clean</option></term>
      <listitem>
       <para>
        Output commands to <command>DROP</command> all the dumped
        database objects prior to outputting the commands for creating them.
        This option is useful when the restore is to overwrite an existing
        database.  If any of the objects do not exist in the destination
        database, ignorable error messages will be reported during
        restore, unless <option>--if-exists</option> is also specified.
       </para>

       <para>
        This option is ignored when emitting an archive (non-text) output
        file.  For the archive formats, you can specify the option when you
        call <command>pg_restore</command>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-C</option></term>
      <term><option>--create</option></term>
      <listitem>
       <para>
        Begin the output with a command to create the
        database itself and reconnect to the created database.  (With a
        script of this form, it doesn't matter which database in the
        destination installation you connect to before running the script.)
        If <option>--clean</option> is also specified, the script drops and
        recreates the target database before reconnecting to it.
       </para>

       <para>
        With <option>--create</option>, the output also includes the
        database's comment if any, and any configuration variable settings
        that are specific to this database, that is,
        any <command>ALTER DATABASE ... SET ...</command>
        and <command>ALTER ROLE ... IN DATABASE ... SET ...</command>
        commands that mention this database.
        Access privileges for the database itself are also dumped,
        unless <option>--no-acl</option> is specified.
       </para>

       <para>
        This option is ignored when emitting an archive (non-text) output
        file.  For the archive formats, you can specify the option when you
        call <command>pg_restore</command>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-e <replaceable class="parameter">pattern</replaceable></option></term>
      <term><option>--extension=<replaceable class="parameter">pattern</replaceable></option></term>
      <listitem>
       <para>
        Dump only extensions matching <replaceable
        class="parameter">pattern</replaceable>.  When this option is not
        specified, all non-system extensions in the target database will be
        dumped.  Multiple extensions can be selected by writing multiple
        <option>-e</option> switches.  The <replaceable
        class="parameter">pattern</replaceable> parameter is interpreted as a
        pattern according to the same rules used by
        <application>psql</application>'s <literal>\d</literal> commands (see
        <xref linkend="app-psql-patterns"/>), so multiple extensions can also
        be selected by writing wildcard characters in the pattern.  When using
        wildcards, be careful to quote the pattern if needed to prevent the
        shell from expanding the wildcards.
       </para>

       <para>
        Any configuration relation registered by
        <function>pg_extension_config_dump</function> is included in the
        dump if its extension is specified by <option>--extension</option>.
       </para>

       <note>
        <para>
         When <option>-e</option> is specified,
         <application>pg_dump</application> makes no attempt to dump any other
         database objects that the selected extension(s) might depend upon.
         Therefore, there is no guarantee that the results of a
         specific-extension dump

Title: pg_dump Options: More Content and Format Controls (-C, -e)
Summary
This section details more pg_dump command-line options. -C/--create begins the output with a command to create the database and reconnect. It includes database comments, configuration variable settings, and access privileges, unless --no-acl is specified. This option is ignored for archive output. -e/--extension allows dumping only extensions matching a specified pattern, using psql's \d command pattern rules. pg_extension_config_dump registered configuration relations are included if their extension is specified.