+ 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.
- The alternative archive file formats that are meant to be used with
- to rebuild the database, and they also
+ The alternative archive file formats must be used with
+ to rebuild the database. They
allow
pg_restore 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
+ large objects>, which is not possible in a script dump.
+ The archive files are also designed to be portable across
architectures.
by default. The
tar format
() 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
tar.
Options
- 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.
dbname
- Specifies the name of the database to be dumped. If this is
- not specified, the environment variable
- PGDATABASE 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
+ PGDATABASE is used. If that is not set, the
+ user name specified for the connection is used.
- Dump only the data, not the object definitions (schema)
+ Dump only the data, not the schema (data definitions).
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 pg_restore.
- Include large objects in dump.
+ Include large objects in the dump. A non-text output format
+ must be selected.
Output commands to clean (drop)
- database objects prior to (the commands for) creating them.
+ database objects prior to (the commands for) creating them.
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 pg_restore.
- 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.)
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 pg_restore.
- Dump data as INSERT commands (rather
- than COPY). This will make restoration very slow;
- it is mainly useful for making dumps that can be loaded into
- non-
PostgreSQL databases. Note that
- the restore may fail altogether if you have rearranged column order.
- The option is safer, though even slower.
+ Dump data as INSERT commands (rather
+ than COPY). This will make restoration very slow;
+ it is mainly useful for making dumps that can be loaded into
+
non-
PostgreSQL databases. Note that
+ the restore may fail altogether if you have rearranged column order.
+ The option is safer, though even slower.
- Dump data as INSERT commands with explicit
- column names (INSERT INTO
- table
- (column, ...) VALUES
- ...). This will make restoration very slow; it is mainly
- useful for making dumps that can be loaded into
- non-
PostgreSQL databases.
+ Dump data as INSERT commands with explicit
+ column names (INSERT INTO
+ table
+ (column, ...) VALUES
+ ...). This will make restoration very slow; it is mainly
+ useful for making dumps that can be loaded into
+
non-
PostgreSQL databases.
- 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.
Selects the format of the output.
- format can be one of the following:
+ format can be one of the following:
In this mode,
pg_dump 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.
- Dump object identifiers (
OIDs) for every
- table. Use this option if your application references the
OID>
- columns in some way (e.g., in a foreign key constraint).
- Otherwise, this option should not be used.
+ Dump object identifiers (
OIDs) as part of the
+ data for every table. Use this option if your application references
+ columns in some way (e.g., in a foreign key constraint).
+ Otherwise, this option should not be used.
Do not output commands to set
- ownership of objects to match the original database.
- By default,
pg_dump issues
- SET SESSION AUTHORIZATION
- 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
+ ownership of objects to match the original database.
+ By default,
pg_dump issues
+ ALTER OWNER> or
+ SET SESSION AUTHORIZATION
+ 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
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 pg_restore.
This option is obsolete but still accepted for backwards
- compatibility.
+ compatibility.
- Dump only the object definitions (schema), not data.
+ Dump only the object definitions (schema), not data.
Specify the superuser user name to use when disabling triggers.
- This is only relevant if
- (Usually, it's better to leave this out, and instead start the
- resulting script as superuser.)
+ This is only relevant if
+ (Usually, it's better to leave this out, and instead start the
+ resulting script as superuser.)
- Dump data for table
- 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
-
+ Dump data for table
+ 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
+
In this mode,
pg_dump 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.
- Specifies verbose mode. This will cause
-
pg_dump to output detailed object
+ Specifies verbose mode. This will cause
+
pg_dump to output detailed object
comments and start/stop times to the dump file, and progress
messages to standard error.
- Prevent dumping of access privileges (grant/revoke commands).
+ Prevent dumping of access privileges (grant/revoke commands).
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 pg_restore.
- 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.
- Specifies the TCP port or local Unix domain socket file
- extension on which the server is listening for connections.
- Defaults to the PGPORT 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 PGPORT environment variable, if
+ set, or a compiled-in default.
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.