Home Explore Blog CI



postgresql

8th chunk of `doc/src/sgml/ref/pg_dump.sgml`
e49d68f72b5329a7c2ca9ac259205bf22aca0fad7cdd31e60000000100000fb1
      <command>SET SESSION AUTHORIZATION</command>
        statements to set ownership of created database objects.
        These statements
        will fail when the script is run unless it is started by a superuser
        (or the same user that owns all of the objects in the script).
        To make a script that can be restored by any user, but will give
        that user ownership of all the objects, specify <option>-O</option>.
       </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>-R</option></term>
      <term><option>--no-reconnect</option></term>
      <listitem>
       <para>
        This option is obsolete but still accepted for backwards
        compatibility.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-s</option></term>
      <term><option>--schema-only</option></term>
      <listitem>
       <para>
        Dump only the object definitions (schema), not data or statistics.
       </para>
       <para>
        This option cannot be used with <option>--data-only</option>
        or <option>--statistics-only</option>.
        It is similar to, but for historical reasons not identical to,
        specifying
        <option>--section=pre-data --section=post-data</option>.
       </para>
       <para>
        (Do not confuse this with the <option>--schema</option> option, which
        uses the word <quote>schema</quote> in a different meaning.)
       </para>
       <para>
        To exclude table data for only a subset of tables in the database,
        see <option>--exclude-table-data</option>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-S <replaceable class="parameter">username</replaceable></option></term>
      <term><option>--superuser=<replaceable class="parameter">username</replaceable></option></term>
      <listitem>
       <para>
        Specify the superuser user name to use when disabling triggers.
        This is relevant only if <option>--disable-triggers</option> is used.
        (Usually, it's better to leave this out, and instead start the
        resulting script as superuser.)
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-t <replaceable class="parameter">pattern</replaceable></option></term>
      <term><option>--table=<replaceable class="parameter">pattern</replaceable></option></term>
      <listitem>
       <para>
        Dump only tables with names matching
        <replaceable class="parameter">pattern</replaceable>. Multiple tables
        can be selected by writing multiple <option>-t</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 tables 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;  see
        <xref linkend="pg-dump-examples"/> below.
       </para>

       <para>
        As well as tables, this option can be used to dump the definition of matching
        views, materialized views, foreign tables, and sequences.  It will not dump the
        contents of views or materialized views, and the contents of foreign tables will
        only be dumped if the corresponding foreign server is specified with
        <option>--include-foreign-data</option>.
       </para>

       <para>
        The <option>-n</option> and <option>-N</option> switches have no effect when
        <option>-t</option>

Title: pg_dump Options: Ownership, Schema-only, Superuser, and Table Selection
Summary
This section details pg_dump options. It covers `-O/--no-owner`, which skips setting object ownership for cross-user restoration (ignored for archive formats, applicable in pg_restore). It also discusses `-R/--no-reconnect`, now obsolete. Then, it explains `-s/--schema-only`, for dumping only schema definitions, excluding data/statistics (incompatible with `--data-only` and `--statistics-only`). Following is `-S/--superuser`, specifying a superuser for trigger disabling (relevant with `--disable-triggers`). Lastly, `-t/--table` allows dumping specific tables/views/sequences using patterns, similar to psql's `\d` commands, while `-n` and `-N` have no effect when `-t` is used.