to duplicate definitions
of the added objects. To make an empty database without any local
additions, copy from <literal>template0</literal> not <literal>template1</literal>, for example:
<programlisting>
CREATE DATABASE foo WITH TEMPLATE template0;
</programlisting>
</para>
<para>
The limitations of <application>pg_restore</application> are detailed below.
<itemizedlist>
<listitem>
<para>
When restoring data to a pre-existing table and the option
<option>--disable-triggers</option> is used,
<application>pg_restore</application> emits commands
to disable triggers on user tables before inserting the data, then emits commands to
re-enable them after the data has been inserted. If the restore is stopped in the
middle, the system catalogs might be left in the wrong state.
</para>
</listitem>
<listitem>
<para><application>pg_restore</application> cannot restore large objects
selectively; for instance, only those for a specific table. If
an archive contains large objects, then all large objects will be
restored, or none of them if they are excluded via <option>-L</option>,
<option>-t</option>, or other options.
</para>
</listitem>
</itemizedlist>
</para>
<para>
See also the <xref linkend="app-pgdump"/> documentation for details on
limitations of <application>pg_dump</application>.
</para>
<para>
By default, <command>pg_restore</command> will restore optimizer statistics
if included in the dump file. If not all statistics were restored, it may
be useful to run <command>ANALYZE</command> on each restored table so the
optimizer has useful statistics; see <xref
linkend="vacuum-for-statistics"/> and <xref linkend="autovacuum"/> for more
information.
</para>
</refsect1>
<refsect1 id="app-pgrestore-examples">
<title>Examples</title>
<para>
Assume we have dumped a database called <literal>mydb</literal> into a
custom-format dump file:
<screen>
<prompt>$</prompt> <userinput>pg_dump -Fc mydb > db.dump</userinput>
</screen>
</para>
<para>
To drop the database and recreate it from the dump:
<screen>
<prompt>$</prompt> <userinput>dropdb mydb</userinput>
<prompt>$</prompt> <userinput>pg_restore -C -d postgres db.dump</userinput>
</screen>
The database named in the <option>-d</option> switch can be any database existing
in the cluster; <application>pg_restore</application> only uses it