|
|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
<!-- |
|
|
|
|
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.74 2004/10/21 22:48:54 tgl Exp $ |
|
|
|
|
$PostgreSQL: pgsql/doc/src/sgml/ref/pg_dump.sgml,v 1.75 2005/01/04 03:58:16 tgl Exp $ |
|
|
|
|
PostgreSQL documentation |
|
|
|
|
--> |
|
|
|
|
|
|
|
|
|
@ -45,21 +45,24 @@ PostgreSQL documentation |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
Dumps can be output in script or archive file formats. The script |
|
|
|
|
files are in plain-text format and contain the SQL commands required |
|
|
|
|
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 these scripts, use <xref linkend="app-psql">. They |
|
|
|
|
saved. To restore from such a script, feed it to <xref |
|
|
|
|
linkend="app-psql">. Script files |
|
|
|
|
can be used to reconstruct the database even on other machines and |
|
|
|
|
other architectures, with some modifications even on other SQL |
|
|
|
|
other architectures; with some modifications even on other SQL |
|
|
|
|
database products. |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
The alternative archive file formats that are meant to be used with |
|
|
|
|
<xref linkend="app-pgrestore"> to rebuild the database, and they also |
|
|
|
|
The alternative archive file formats must be used with |
|
|
|
|
<xref linkend="app-pgrestore"> to rebuild the database. They |
|
|
|
|
allow <application>pg_restore</application> to be selective about |
|
|
|
|
what is restored, or even to reorder the items prior to being |
|
|
|
|
restored. The archive files are also designed to be portable across |
|
|
|
|
restored. The archive formats also allow saving and restoring |
|
|
|
|
<quote>large objects</>, which is not possible in a script dump. |
|
|
|
|
The archive files are also designed to be portable across |
|
|
|
|
architectures. |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
@ -76,7 +79,7 @@ PostgreSQL documentation |
|
|
|
|
by default. The <application>tar</application> format |
|
|
|
|
(<option>-Ft</option>) 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 other tools such as |
|
|
|
|
moreover, it can be manipulated with standard Unix tools such as |
|
|
|
|
<command>tar</command>. |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
@ -92,17 +95,18 @@ PostgreSQL documentation |
|
|
|
|
<title>Options</title> |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
The following command-line options are used to control the output format. |
|
|
|
|
The following command-line options control the content and |
|
|
|
|
format of the output. |
|
|
|
|
|
|
|
|
|
<variablelist> |
|
|
|
|
<varlistentry> |
|
|
|
|
<term><replaceable class="parameter">dbname</replaceable></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Specifies the name of the database to be dumped. If this is |
|
|
|
|
not specified, the environment variable |
|
|
|
|
<envar>PGDATABASE</envar> is used. If that is not set, the |
|
|
|
|
user name specified for the connection is used. |
|
|
|
|
Specifies the name of the database to be dumped. If this is |
|
|
|
|
not specified, the environment variable |
|
|
|
|
<envar>PGDATABASE</envar> is used. If that is not set, the |
|
|
|
|
user name specified for the connection is used. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -112,12 +116,12 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--data-only</></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Dump only the data, not the object definitions (schema) |
|
|
|
|
Dump only the data, not the schema (data definitions). |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
This option is only meaningful for the plain-text format. For |
|
|
|
|
the other formats, you may specify the option when you |
|
|
|
|
the archive formats, you may specify the option when you |
|
|
|
|
call <command>pg_restore</command>. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
@ -128,7 +132,8 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--blobs</></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Include large objects in dump. |
|
|
|
|
Include large objects in the dump. A non-text output format |
|
|
|
|
must be selected. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -139,12 +144,12 @@ PostgreSQL documentation |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Output commands to clean (drop) |
|
|
|
|
database objects prior to (the commands for) creating them. |
|
|
|
|
database objects prior to (the commands for) creating them. |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
This option is only meaningful for the plain-text format. For |
|
|
|
|
the other formats, you may specify the option when you |
|
|
|
|
the archive formats, you may specify the option when you |
|
|
|
|
call <command>pg_restore</command>. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
@ -155,15 +160,15 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--create</></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 you connect |
|
|
|
|
to before running the script.) |
|
|
|
|
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.) |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
This option is only meaningful for the plain-text format. For |
|
|
|
|
the other formats, you may specify the option when you |
|
|
|
|
the archive formats, you may specify the option when you |
|
|
|
|
call <command>pg_restore</command>. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
@ -174,12 +179,12 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--inserts</option></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Dump data as <command>INSERT</command> commands (rather |
|
|
|
|
than <command>COPY</command>). This will make restoration very slow; |
|
|
|
|
it is mainly useful for making dumps that can be loaded into |
|
|
|
|
non-<productname>PostgreSQL</productname> databases. Note that |
|
|
|
|
the restore may fail altogether if you have rearranged column order. |
|
|
|
|
The <option>-D</option> option is safer, though even slower. |
|
|
|
|
Dump data as <command>INSERT</command> commands (rather |
|
|
|
|
than <command>COPY</command>). This will make restoration very slow; |
|
|
|
|
it is mainly useful for making dumps that can be loaded into |
|
|
|
|
non-<productname>PostgreSQL</productname> databases. Note that |
|
|
|
|
the restore may fail altogether if you have rearranged column order. |
|
|
|
|
The <option>-D</option> option is safer, though even slower. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -190,13 +195,13 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--attribute-inserts</option></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Dump data as <command>INSERT</command> commands with explicit |
|
|
|
|
column names (<literal>INSERT INTO |
|
|
|
|
<replaceable>table</replaceable> |
|
|
|
|
(<replaceable>column</replaceable>, ...) VALUES |
|
|
|
|
...</literal>). This will make restoration very slow; it is mainly |
|
|
|
|
useful for making dumps that can be loaded into |
|
|
|
|
non-<productname>PostgreSQL</productname> databases. |
|
|
|
|
Dump data as <command>INSERT</command> commands with explicit |
|
|
|
|
column names (<literal>INSERT INTO |
|
|
|
|
<replaceable>table</replaceable> |
|
|
|
|
(<replaceable>column</replaceable>, ...) VALUES |
|
|
|
|
...</literal>). This will make restoration very slow; it is mainly |
|
|
|
|
useful for making dumps that can be loaded into |
|
|
|
|
non-<productname>PostgreSQL</productname> databases. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -206,8 +211,8 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--file=<replaceable class="parameter">file</replaceable></option></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Send output to the specified file. If this is omitted, the |
|
|
|
|
standard output is used. |
|
|
|
|
Send output to the specified file. If this is omitted, the |
|
|
|
|
standard output is used. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -218,7 +223,7 @@ PostgreSQL documentation |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Selects the format of the output. |
|
|
|
|
<replaceable>format</replaceable> can be one of the following: |
|
|
|
|
<replaceable>format</replaceable> can be one of the following: |
|
|
|
|
|
|
|
|
|
<variablelist> |
|
|
|
|
<varlistentry> |
|
|
|
|
@ -295,7 +300,7 @@ PostgreSQL documentation |
|
|
|
|
<para> |
|
|
|
|
In this mode, <application>pg_dump</application> makes no |
|
|
|
|
attempt to dump any other database objects that objects in the |
|
|
|
|
selected schema may depend upon. Therefore, there is no |
|
|
|
|
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. |
|
|
|
|
</para> |
|
|
|
|
@ -308,10 +313,11 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--oids</></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Dump object identifiers (<acronym>OID</acronym>s) for every |
|
|
|
|
table. Use this option if your application references the <acronym>OID</> |
|
|
|
|
columns in some way (e.g., in a foreign key constraint). |
|
|
|
|
Otherwise, this option should not be used. |
|
|
|
|
Dump object identifiers (<acronym>OID</acronym>s) as part of the |
|
|
|
|
data for every table. Use this option if your application references |
|
|
|
|
the <acronym>OID</> |
|
|
|
|
columns in some way (e.g., in a foreign key constraint). |
|
|
|
|
Otherwise, this option should not be used. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -322,20 +328,21 @@ PostgreSQL documentation |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Do not output commands to set |
|
|
|
|
ownership of objects to match the original database. |
|
|
|
|
By default, <application>pg_dump</application> issues |
|
|
|
|
<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</>. |
|
|
|
|
ownership of objects to match the original database. |
|
|
|
|
By default, <application>pg_dump</application> issues |
|
|
|
|
<command>ALTER OWNER</> or |
|
|
|
|
<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</>. |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
This option is only meaningful for the plain-text format. For |
|
|
|
|
the other formats, you may specify the option when you |
|
|
|
|
the archive formats, you may specify the option when you |
|
|
|
|
call <command>pg_restore</command>. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
@ -347,7 +354,7 @@ PostgreSQL documentation |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
This option is obsolete but still accepted for backwards |
|
|
|
|
compatibility. |
|
|
|
|
compatibility. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -357,7 +364,7 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--schema-only</option></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Dump only the object definitions (schema), not data. |
|
|
|
|
Dump only the object definitions (schema), not data. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -368,9 +375,9 @@ PostgreSQL documentation |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Specify the superuser user name to use when disabling triggers. |
|
|
|
|
This is only relevant if <option>--disable-triggers</> is used. |
|
|
|
|
(Usually, it's better to leave this out, and instead start the |
|
|
|
|
resulting script as superuser.) |
|
|
|
|
This is only relevant if <option>--disable-triggers</> is used. |
|
|
|
|
(Usually, it's better to leave this out, and instead start the |
|
|
|
|
resulting script as superuser.) |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -380,18 +387,18 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--table=<replaceable class="parameter">table</replaceable></option></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Dump data for <replaceable class="parameter">table</replaceable> |
|
|
|
|
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 |
|
|
|
|
<option>--schema</> and <option>--table</> to select just one table. |
|
|
|
|
Dump data for <replaceable class="parameter">table</replaceable> |
|
|
|
|
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 |
|
|
|
|
<option>--schema</> and <option>--table</> to select just one table. |
|
|
|
|
</para> |
|
|
|
|
|
|
|
|
|
<note> |
|
|
|
|
<para> |
|
|
|
|
In this mode, <application>pg_dump</application> makes no |
|
|
|
|
attempt to dump any other database objects that the selected table |
|
|
|
|
may depend upon. Therefore, there is no guarantee |
|
|
|
|
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. |
|
|
|
|
</para> |
|
|
|
|
@ -404,8 +411,8 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--verbose</></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Specifies verbose mode. This will cause |
|
|
|
|
<application>pg_dump</application> to output detailed object |
|
|
|
|
Specifies verbose mode. This will cause |
|
|
|
|
<application>pg_dump</application> to output detailed object |
|
|
|
|
comments and start/stop times to the dump file, and progress |
|
|
|
|
messages to standard error. |
|
|
|
|
</para> |
|
|
|
|
@ -418,7 +425,7 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--no-acl</></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Prevent dumping of access privileges (grant/revoke commands). |
|
|
|
|
Prevent dumping of access privileges (grant/revoke commands). |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -456,7 +463,7 @@ PostgreSQL documentation |
|
|
|
|
|
|
|
|
|
<para> |
|
|
|
|
This option is only meaningful for the plain-text format. For |
|
|
|
|
the other formats, you may specify the option when you |
|
|
|
|
the archive formats, you may specify the option when you |
|
|
|
|
call <command>pg_restore</command>. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
@ -467,10 +474,10 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--use-set-session-authorization</></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Output SQL standard SET SESSION AUTHORIZATION commands instead |
|
|
|
|
of OWNER TO commands. This makes the dump more standards compatible, |
|
|
|
|
but depending on the history of the objects in the dump, may not |
|
|
|
|
restore properly. |
|
|
|
|
Output SQL standard SET SESSION AUTHORIZATION commands instead |
|
|
|
|
of OWNER TO commands. This makes the dump more standards compatible, |
|
|
|
|
but depending on the history of the objects in the dump, may not |
|
|
|
|
restore properly. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -512,10 +519,10 @@ PostgreSQL documentation |
|
|
|
|
<term><option>--port=<replaceable class="parameter">port</replaceable></option></term> |
|
|
|
|
<listitem> |
|
|
|
|
<para> |
|
|
|
|
Specifies the TCP port or local Unix domain socket file |
|
|
|
|
extension on which the server is listening for connections. |
|
|
|
|
Defaults to the <envar>PGPORT</envar> environment variable, if |
|
|
|
|
set, or a compiled-in default. |
|
|
|
|
Specifies the TCP port or local Unix domain socket file |
|
|
|
|
extension on which the server is listening for connections. |
|
|
|
|
Defaults to the <envar>PGPORT</envar> environment variable, if |
|
|
|
|
set, or a compiled-in default. |
|
|
|
|
</para> |
|
|
|
|
</listitem> |
|
|
|
|
</varlistentry> |
|
|
|
|
@ -619,7 +626,7 @@ CREATE DATABASE foo WITH TEMPLATE template0; |
|
|
|
|
<para> |
|
|
|
|
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 a table |
|
|
|
|
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. |
|
|
|
|
|