|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /proc/self/root/usr/share/doc/postgresql-8.1.9/html/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pg_dump</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.1.9 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="PostgreSQL Client Applications"
HREF="reference-client.html"><LINK
REL="PREVIOUS"
TITLE="pg_config"
HREF="app-pgconfig.html"><LINK
REL="NEXT"
TITLE="pg_dumpall"
HREF="app-pg-dumpall.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2007-04-20T04:40:08"></HEAD
><BODY
CLASS="REFENTRY"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.1.9 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-pgconfig.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-pgconfig.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pg-dumpall.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pg-dumpall.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="APP-PGDUMP"
></A
>pg_dump</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN51015"
></A
><H2
>Name</H2
>pg_dump -- extract a <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> database into a script file or other archive file
</DIV
><A
NAME="AEN51019"
></A
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN51021"
></A
><H2
>Synopsis</H2
><P
><TT
CLASS="COMMAND"
>pg_dump</TT
> [<TT
CLASS="REPLACEABLE"
><I
>option</I
></TT
>...] [<TT
CLASS="REPLACEABLE"
><I
>dbname</I
></TT
>]</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="PG-DUMP-DESCRIPTION"
></A
><H2
> Description
</H2
><P
> <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> is a utility for backing up a
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> database. It makes consistent
backups even if the database is being used concurrently.
<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> does not block other users
accessing the database (readers or writers).
</P
><P
> Dumps can be output in script or archive file formats. Script
dumps are plain-text files containing the SQL commands required
to reconstruct the database to the state it was in at the time it was
saved. To restore from such a script, feed it to <A
HREF="app-psql.html"
><SPAN
CLASS="APPLICATION"
>psql</SPAN
></A
>. Script files
can be used to reconstruct the database even on other machines and
other architectures; with some modifications even on other SQL
database products.
</P
><P
> The alternative archive file formats must be used with
<A
HREF="app-pgrestore.html"
>pg_restore</A
> to rebuild the database. They
allow <SPAN
CLASS="APPLICATION"
>pg_restore</SPAN
> to be selective about
what is restored, or even to reorder the items prior to being
restored.
The archive file formats are designed to be portable across
architectures.
</P
><P
> When used with one of the archive file formats and combined with
<SPAN
CLASS="APPLICATION"
>pg_restore</SPAN
>,
<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> provides a flexible archival and
transfer mechanism. <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> can be used to
backup an entire database, then <SPAN
CLASS="APPLICATION"
>pg_restore</SPAN
>
can be used to examine the archive and/or select which parts of the
database are to be restored. The most flexible output file format is
the <SPAN
CLASS="QUOTE"
>"custom"</SPAN
> format (<TT
CLASS="OPTION"
>-Fc</TT
>). It allows
for selection and reordering of all archived items, and is compressed
by default. The <SPAN
CLASS="APPLICATION"
>tar</SPAN
> format
(<TT
CLASS="OPTION"
>-Ft</TT
>) is not compressed and it is not possible to
reorder data when loading, but it is otherwise quite flexible;
moreover, it can be manipulated with standard Unix tools such as
<TT
CLASS="COMMAND"
>tar</TT
>.
</P
><P
> While running <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
>, one should examine the
output for any warnings (printed on standard error), especially in
light of the limitations listed below.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="PG-DUMP-OPTIONS"
></A
><H2
>Options</H2
><P
> The following command-line options control the content and
format of the output.
<P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="REPLACEABLE"
><I
>dbname</I
></TT
></DT
><DD
><P
> Specifies the name of the database to be dumped. If this is
not specified, the environment variable
<TT
CLASS="ENVAR"
>PGDATABASE</TT
> is used. If that is not set, the
user name specified for the connection is used.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-a</TT
><BR><TT
CLASS="OPTION"
>--data-only</TT
></DT
><DD
><P
> Dump only the data, not the schema (data definitions).
</P
><P
> This option is only meaningful for the plain-text format. For
the archive formats, you may specify the option when you
call <TT
CLASS="COMMAND"
>pg_restore</TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-c</TT
><BR><TT
CLASS="OPTION"
>--clean</TT
></DT
><DD
><P
> Output commands to clean (drop)
database objects prior to (the commands for) creating them.
</P
><P
> This option is only meaningful for the plain-text format. For
the archive formats, you may specify the option when you
call <TT
CLASS="COMMAND"
>pg_restore</TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-C</TT
><BR><TT
CLASS="OPTION"
>--create</TT
></DT
><DD
><P
> 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 you connect
to before running the script.)
</P
><P
> This option is only meaningful for the plain-text format. For
the archive formats, you may specify the option when you
call <TT
CLASS="COMMAND"
>pg_restore</TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-d</TT
><BR><TT
CLASS="OPTION"
>--inserts</TT
></DT
><DD
><P
> Dump data as <TT
CLASS="COMMAND"
>INSERT</TT
> commands (rather
than <TT
CLASS="COMMAND"
>COPY</TT
>). This will make restoration very slow;
it is mainly useful for making dumps that can be loaded into
non-<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases. Note that
the restore may fail altogether if you have rearranged column order.
The <TT
CLASS="OPTION"
>-D</TT
> option is safer, though even slower.
Also, while this option generates errors for invalid data,
it allows other <TT
CLASS="COMMAND"
>INSERT</TT
>s to continue loading
data into the table.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-D</TT
><BR><TT
CLASS="OPTION"
>--column-inserts</TT
><BR><TT
CLASS="OPTION"
>--attribute-inserts</TT
></DT
><DD
><P
> Dump data as <TT
CLASS="COMMAND"
>INSERT</TT
> commands with explicit
column names (<TT
CLASS="LITERAL"
>INSERT INTO
<TT
CLASS="REPLACEABLE"
><I
>table</I
></TT
>
(<TT
CLASS="REPLACEABLE"
><I
>column</I
></TT
>, ...) VALUES
...</TT
>). This will make restoration very slow; it is mainly
useful for making dumps that can be loaded into
non-<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases.
Also, while this option generates errors for invalid data,
it allows other <TT
CLASS="COMMAND"
>INSERT</TT
>s to continue loading
data into the table.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-E <TT
CLASS="REPLACEABLE"
><I
>encoding</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--encoding=<TT
CLASS="REPLACEABLE"
><I
>encoding</I
></TT
></TT
></DT
><DD
><P
> Create the dump in the specified character set encoding. By default,
the dump is created in the database encoding. (Another way to get the
same result is to set the <TT
CLASS="ENVAR"
>PGCLIENTENCODING</TT
> environment
variable to the desired dump encoding.)
</P
></DD
><DT
><TT
CLASS="OPTION"
>-f <TT
CLASS="REPLACEABLE"
><I
>file</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--file=<TT
CLASS="REPLACEABLE"
><I
>file</I
></TT
></TT
></DT
><DD
><P
> Send output to the specified file. If this is omitted, the
standard output is used.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-F <TT
CLASS="REPLACEABLE"
><I
>format</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--format=<TT
CLASS="REPLACEABLE"
><I
>format</I
></TT
></TT
></DT
><DD
><P
> Selects the format of the output.
<TT
CLASS="REPLACEABLE"
><I
>format</I
></TT
> can be one of the following:
<P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>p</TT
></DT
><DD
><P
> Output a plain-text <ACRONYM
CLASS="ACRONYM"
>SQL</ACRONYM
> script file (default)
</P
></DD
><DT
><TT
CLASS="LITERAL"
>t</TT
></DT
><DD
><P
> Output a <TT
CLASS="COMMAND"
>tar</TT
> archive suitable for input into
<SPAN
CLASS="APPLICATION"
>pg_restore</SPAN
>. Using this archive format
allows reordering and/or exclusion of database objects
at the time the database is restored. It is also possible to limit
which data is reloaded at restore time.
</P
></DD
><DT
><TT
CLASS="LITERAL"
>c</TT
></DT
><DD
><P
> Output a custom archive suitable for input into
<SPAN
CLASS="APPLICATION"
>pg_restore</SPAN
>. This is the most flexible
format in that it allows reordering of loading data as well
as object definitions. This format is also compressed by default.
</P
></DD
></DL
></DIV
><P>
</P
></DD
><DT
><TT
CLASS="OPTION"
>-i</TT
><BR><TT
CLASS="OPTION"
>--ignore-version</TT
></DT
><DD
><P
> Ignore version mismatch between
<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> and the database server.
</P
><P
> <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> can handle databases from
previous releases of <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>, but very old
versions are not supported anymore (currently prior to 7.0).
Use this option if you need to override the version check (and
if <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> then fails, don't say
you weren't warned).
</P
></DD
><DT
><TT
CLASS="OPTION"
>-n <TT
CLASS="REPLACEABLE"
><I
>schema</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--schema=<TT
CLASS="REPLACEABLE"
><I
>schema</I
></TT
></TT
></DT
><DD
><P
> Dump the contents of <TT
CLASS="REPLACEABLE"
><I
>schema</I
></TT
>
only. If this option is not specified, all non-system schemas
in the target database will be dumped.
</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
> In this mode, <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> makes no
attempt to dump any other database objects that objects in the
selected schema may depend upon. Therefore, there is no
guarantee that the results of a single-schema dump can be
successfully restored by themselves into a clean database.
</P
></BLOCKQUOTE
></DIV
></DD
><DT
><TT
CLASS="OPTION"
>-o</TT
><BR><TT
CLASS="OPTION"
>--oids</TT
></DT
><DD
><P
> Dump object identifiers (<ACRONYM
CLASS="ACRONYM"
>OID</ACRONYM
>s) as part of the
data for every table. Use this option if your application references
the <ACRONYM
CLASS="ACRONYM"
>OID</ACRONYM
>
columns in some way (e.g., in a foreign key constraint).
Otherwise, this option should not be used.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-O</TT
><BR><TT
CLASS="OPTION"
>--no-owner</TT
></DT
><DD
><P
> Do not output commands to set
ownership of objects to match the original database.
By default, <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> issues
<TT
CLASS="COMMAND"
>ALTER OWNER</TT
> or
<TT
CLASS="COMMAND"
>SET SESSION AUTHORIZATION</TT
>
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 <TT
CLASS="OPTION"
>-O</TT
>.
</P
><P
> This option is only meaningful for the plain-text format. For
the archive formats, you may specify the option when you
call <TT
CLASS="COMMAND"
>pg_restore</TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-R</TT
><BR><TT
CLASS="OPTION"
>--no-reconnect</TT
></DT
><DD
><P
> This option is obsolete but still accepted for backwards
compatibility.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-s</TT
><BR><TT
CLASS="OPTION"
>--schema-only</TT
></DT
><DD
><P
> Dump only the object definitions (schema), not data.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-S <TT
CLASS="REPLACEABLE"
><I
>username</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--superuser=<TT
CLASS="REPLACEABLE"
><I
>username</I
></TT
></TT
></DT
><DD
><P
> Specify the superuser user name to use when disabling triggers.
This is only relevant if <TT
CLASS="OPTION"
>--disable-triggers</TT
> is used.
(Usually, it's better to leave this out, and instead start the
resulting script as superuser.)
</P
></DD
><DT
><TT
CLASS="OPTION"
>-t <TT
CLASS="REPLACEABLE"
><I
>table</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--table=<TT
CLASS="REPLACEABLE"
><I
>table</I
></TT
></TT
></DT
><DD
><P
> Dump data for <TT
CLASS="REPLACEABLE"
><I
>table</I
></TT
>
only. It is possible for there to be
multiple tables with the same name in different schemas; if that
is the case, all matching tables will be dumped. Specify both
<TT
CLASS="OPTION"
>--schema</TT
> and <TT
CLASS="OPTION"
>--table</TT
> to select just one table.
</P
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
> In this mode, <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> makes no
attempt to dump any other database objects that the selected table
may depend upon. Therefore, there is no guarantee
that the results of a single-table dump can be successfully
restored by themselves into a clean database.
</P
></BLOCKQUOTE
></DIV
></DD
><DT
><TT
CLASS="OPTION"
>-v</TT
><BR><TT
CLASS="OPTION"
>--verbose</TT
></DT
><DD
><P
> Specifies verbose mode. This will cause
<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> to output detailed object
comments and start/stop times to the dump file, and progress
messages to standard error.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-x</TT
><BR><TT
CLASS="OPTION"
>--no-privileges</TT
><BR><TT
CLASS="OPTION"
>--no-acl</TT
></DT
><DD
><P
> Prevent dumping of access privileges (grant/revoke commands).
</P
></DD
><DT
><TT
CLASS="OPTION"
>-X disable-dollar-quoting</TT
><BR><TT
CLASS="OPTION"
>--disable-dollar-quoting</TT
></DT
><DD
><P
> This option disables the use of dollar quoting for function bodies,
and forces them to be quoted using SQL standard string syntax.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-X disable-triggers</TT
><BR><TT
CLASS="OPTION"
>--disable-triggers</TT
></DT
><DD
><P
> This option is only relevant when creating a data-only dump.
It instructs <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> to include commands
to temporarily disable triggers on the target tables while
the data is reloaded. Use this if you have referential
integrity checks or other triggers on the tables that you
do not want to invoke during data reload.
</P
><P
> Presently, the commands emitted for <TT
CLASS="OPTION"
>--disable-triggers</TT
>
must be done as superuser. So, you should also specify
a superuser name with <TT
CLASS="OPTION"
>-S</TT
>, or preferably be careful to
start the resulting script as a superuser.
</P
><P
> This option is only meaningful for the plain-text format. For
the archive formats, you may specify the option when you
call <TT
CLASS="COMMAND"
>pg_restore</TT
>.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-X use-set-session-authorization</TT
><BR><TT
CLASS="OPTION"
>--use-set-session-authorization</TT
></DT
><DD
><P
> Output SQL-standard <TT
CLASS="COMMAND"
>SET SESSION AUTHORIZATION</TT
> commands
instead of <TT
CLASS="COMMAND"
>ALTER OWNER</TT
> commands to determine object
ownership. This makes the dump more standards compatible, but
depending on the history of the objects in the dump, may not restore
properly. Also, a dump using <TT
CLASS="COMMAND"
>SET SESSION AUTHORIZATION</TT
>
will certainly require superuser privileges to restore correctly,
whereas <TT
CLASS="COMMAND"
>ALTER OWNER</TT
> requires lesser privileges.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-Z <TT
CLASS="REPLACEABLE"
><I
>0..9</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--compress=<TT
CLASS="REPLACEABLE"
><I
>0..9</I
></TT
></TT
></DT
><DD
><P
> Specify the compression level to use in archive formats that
support compression. (Currently only the custom archive
format supports compression.)
</P
></DD
></DL
></DIV
><P>
</P
><P
> The following command-line options control the database connection parameters.
<P
></P
></P><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="OPTION"
>-h <TT
CLASS="REPLACEABLE"
><I
>host</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--host=<TT
CLASS="REPLACEABLE"
><I
>host</I
></TT
></TT
></DT
><DD
><P
> Specifies the host name of the machine on which the server is
running. If the value begins with a slash, it is used as the
directory for the Unix domain socket. The default is taken
from the <TT
CLASS="ENVAR"
>PGHOST</TT
> environment variable, if set,
else a Unix domain socket connection is attempted.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-p <TT
CLASS="REPLACEABLE"
><I
>port</I
></TT
></TT
><BR><TT
CLASS="OPTION"
>--port=<TT
CLASS="REPLACEABLE"
><I
>port</I
></TT
></TT
></DT
><DD
><P
> Specifies the TCP port or local Unix domain socket file
extension on which the server is listening for connections.
Defaults to the <TT
CLASS="ENVAR"
>PGPORT</TT
> environment variable, if
set, or a compiled-in default.
</P
></DD
><DT
><TT
CLASS="OPTION"
>-U <TT
CLASS="REPLACEABLE"
><I
>username</I
></TT
></TT
></DT
><DD
><P
> Connect as the given user
</P
></DD
><DT
><TT
CLASS="OPTION"
>-W</TT
></DT
><DD
><P
> Force a password prompt. This should happen automatically if
the server requires password authentication.
</P
></DD
></DL
></DIV
><P>
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN51340"
></A
><H2
>Environment</H2
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="ENVAR"
>PGDATABASE</TT
><BR><TT
CLASS="ENVAR"
>PGHOST</TT
><BR><TT
CLASS="ENVAR"
>PGPORT</TT
><BR><TT
CLASS="ENVAR"
>PGUSER</TT
></DT
><DD
><P
> Default connection parameters.
</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="APP-PGDUMP-DIAGNOSTICS"
></A
><H2
>Diagnostics</H2
><P
> <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> internally executes
<TT
CLASS="COMMAND"
>SELECT</TT
> statements. If you have problems running
<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
>, make sure you are able to
select information from the database using, for example, <A
HREF="app-psql.html"
><SPAN
CLASS="APPLICATION"
>psql</SPAN
></A
>.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="PG-DUMP-NOTES"
></A
><H2
>Notes</H2
><P
> If your database cluster has any local additions to the <TT
CLASS="LITERAL"
>template1</TT
> database,
be careful to restore the output of <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> into a
truly empty database; otherwise you are likely to get errors due to
duplicate definitions of the added objects. To make an empty database
without any local additions, copy from <TT
CLASS="LITERAL"
>template0</TT
> not <TT
CLASS="LITERAL"
>template1</TT
>,
for example:
</P><PRE
CLASS="PROGRAMLISTING"
>CREATE DATABASE foo WITH TEMPLATE template0;</PRE
><P>
</P
><P
> <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> has a few limitations:
<P
></P
></P><UL
><LI
><P
> When a data-only dump is chosen and the option
<TT
CLASS="OPTION"
>--disable-triggers</TT
> is used,
<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> emits commands to disable
triggers on user tables before inserting the data and commands
to re-enable them after the data has been inserted. If the
restore is stopped in the middle, the system catalogs may be
left in the wrong state.
</P
></LI
></UL
><P>
</P
><P
> Members of tar archives are limited to a size less than 8 GB.
(This is an inherent limitation of the tar file format.) Therefore
this format cannot be used if the textual representation of any one table
exceeds that size. The total size of a tar archive and any of the
other output formats is not limited, except possibly by the
operating system.
</P
><P
> The dump file produced by <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> does
not contain the statistics used by the optimizer to make query
planning decisions. Therefore, it is wise to run
<TT
CLASS="COMMAND"
>ANALYZE</TT
> after restoring from a dump file to
ensure good performance.
</P
><P
> Because <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> is used to tranfer data
to newer versions of <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
>, the output of
<SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> can be loaded into
newer <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases. It also can read older
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases. However, it usually cannot
read newer <SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> databases or produce dump output
that can be loaded into older database versions. To do this, manual
editing of the dump file might be required.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="PG-DUMP-EXAMPLES"
></A
><H2
>Examples</H2
><P
> To dump a database:
</P><PRE
CLASS="SCREEN"
><SAMP
CLASS="PROMPT"
>$</SAMP
> <KBD
CLASS="USERINPUT"
>pg_dump mydb > db.out</KBD
></PRE
><P>
</P
><P
> To reload this database:
</P><PRE
CLASS="SCREEN"
><SAMP
CLASS="PROMPT"
>$</SAMP
> <KBD
CLASS="USERINPUT"
>psql -d database -f db.out</KBD
></PRE
><P>
</P
><P
> To dump a database called <TT
CLASS="LITERAL"
>mydb</TT
> to a <TT
CLASS="FILENAME"
>tar</TT
>
file:
</P><PRE
CLASS="SCREEN"
><SAMP
CLASS="PROMPT"
>$</SAMP
> <KBD
CLASS="USERINPUT"
>pg_dump -Ft mydb > db.tar</KBD
></PRE
><P>
</P
><P
> To reload this dump into an existing database called <TT
CLASS="LITERAL"
>newdb</TT
>:
</P><PRE
CLASS="SCREEN"
><SAMP
CLASS="PROMPT"
>$</SAMP
> <KBD
CLASS="USERINPUT"
>pg_restore -d newdb db.tar</KBD
></PRE
><P>
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN51408"
></A
><H2
>History</H2
><P
> The <SPAN
CLASS="APPLICATION"
>pg_dump</SPAN
> utility first appeared in
<SPAN
CLASS="APPLICATION"
>Postgres95</SPAN
> release 0.02. The
non-plain-text output formats were introduced in
<SPAN
CLASS="PRODUCTNAME"
>PostgreSQL</SPAN
> release 7.1.
</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN51414"
></A
><H2
>See Also</H2
><A
HREF="app-pg-dumpall.html"
><SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
></A
>, <A
HREF="app-pgrestore.html"
>pg_restore</A
>, <A
HREF="app-psql.html"
><SPAN
CLASS="APPLICATION"
>psql</SPAN
></A
>, Environment Variables (<A
HREF="libpq-envars.html"
>Section 28.11</A
>)</DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="app-pgconfig.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="app-pg-dumpall.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>pg_config</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference-client.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><SPAN
CLASS="APPLICATION"
>pg_dumpall</SPAN
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>