saved. To restore from such a script, feed it to
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.
than COPY). This will make restoration very slow;
it is mainly useful for making dumps that can be loaded into
non-
PostgreSQL databases.
- Also, since this option generates a separate command for each row,
+ However, since this option generates a separate command for each row,
an error in reloading a row causes only that row to be lost rather
than the entire table contents.
Note that
...). This will make restoration very slow; it is mainly
useful for making dumps that can be loaded into
non-
PostgreSQL databases.
- Also, since this option generates a separate command for each row,
+ However, since this option generates a separate command for each row,
an error in reloading a row causes only that row to be lost rather
than the entire table contents.
Output SQL-standard SET SESSION AUTHORIZATION> commands
instead of ALTER OWNER> commands to determine object
- ownership. This makes the dump more standards compatible, but
+ ownership. This makes the dump more standards-compatible, but
depending on the history of the objects in the dump, might not restore
properly. Also, a dump using SET SESSION AUTHORIZATION>
will certainly require superuser privileges to restore correctly,
does not contain the statistics used by the optimizer to make
query planning decisions. Therefore, it is wise to run
ANALYZE after restoring from a dump file
- to ensure good performance; see
+ to ensure optimal performance; see
and for more information.
The dump file also does not
contain any ALTER DATABASE ... SET> commands;
pg_dumpall
- The SQL script will be written to the standard output. Shell
- operators should be used to redirect it into a file.
+ The SQL script will be written to the standard output. Use the
+ [-f|file] option or shell operators to redirect it into a file.
Do not wait forever to acquire shared table locks at the beginning of
- the dump. Instead fail if unable to lock a table within the specified
+ the dump. Instead, fail if unable to lock a table within the specified
timeout>. The timeout may be
specified in any of the formats accepted by SET
- statement_timeout>. (Allowed values vary depending on the server
+ statement_timeout>. Allowed values vary depending on the server
version you are dumping from, but an integer number of milliseconds
is accepted by all versions since 7.3. This option is ignored when
- dumping from a pre-7.3 server.)
+ dumping from a pre-7.3 server.
pg_dumpall requires all needed
- tablespace directories to exist before the restore, else
+ tablespace directories to exist before the restore; otherwise,
database creation will fail for databases in non-default
locations.
- To reload this database use, for example:
+ To reload database(s) from this file, you can use:
$ psql -f db.out postgres
-
+
pg_restore
good place to start is the number of CPU cores on the server,
but values larger than that can also lead to faster restore
times in many cases. Of course, values that are too high will
- lead to decreasing performance because of thrashing.
+ lead to decreased performance because of thrashing.
Restore only the schema (data definitions), not the data (table
- contents). Sequence current values will not be restored, either.
+ contents). Current sequence values will not be restored, either.
(Do not confuse this with the
uses the word schema> in a different meaning.)
Output SQL-standard SET SESSION AUTHORIZATION> commands
instead of ALTER OWNER> commands to determine object
- ownership. This makes the dump more standards compatible, but
+ ownership. This makes the dump more standards-compatible, but
depending on the history of the objects in the dump, might not restore
properly.
When restoring data to a pre-existing table and the option
pg_restore emits commands
- to disable triggers on user tables before inserting the data then emits commands to
+ 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.
pg_restore cannot restore large objects
- selectively, for instance only those for a specific table. If
+ 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 ,
, or other options.
Print all input lines to standard output as they are read. This is more
- useful for script processing rather than interactive mode. This is
+ useful for script processing than interactive mode. This is
equivalent to setting the variable ECHO to
all.
command must be either
a command string that is completely parsable by the server (i.e.,
- it contains no
psql specific features),
+ it contains no
psql-specific features),
or a single backslash command. Thus you cannot mix
meta-commands with this option. To achieve that, you could
numbers. There is also a slight chance that using this option will
reduce the start-up overhead. On the other hand, the variant using
the shell's input redirection is (in theory) guaranteed to yield
- exactly the same output that you would have gotten had you entered
+ exactly the same output you would have received had you entered
everything by hand.
Specifies printing options, in the style of
\pset. Note that here you
have to separate name and value with an equal sign instead of a
- space. Thus to set the output format to LaTeX, you could write
+ space. For example, to set the output format to LaTeX, you could write
-P format=latex.
psql returns 0 to the shell if it
- finished normally, 1 if a fatal error of its own (out of memory,
- file not found) occurs, 2 if the connection to the server went bad
+ finished normally, 1 if a fatal error of its own occurs (e.g. out of memory,
+ file not found), 2 if the connection to the server went bad
and the session was not interactive, and 3 if an error occurred in a
script and the variable ON_ERROR_STOP was set.
PostgreSQL client application. In order
to connect to a database you need to know the name of your target
- database, the host name and port number of the server and what user
+ database, the host name and port number of the server, and what user
name you want to connect as.
psql can be
told about those parameters via command line options, namely
, , , and
respectively. If an argument is found that does
not belong to any option it will be interpreted as the database name
(or the user name, if the database name is already given). Not all
- these options are required; there are useful defaults. If you omit the host
+ of these options are required; there are useful defaults. If you omit the host
name,
psql> will connect via a Unix-domain socket
to a server on the local host, or via TCP/IP to localhost> on
machines that don't have Unix-domain sockets. The default port number is
Anything you enter in
psql that begins
with an unquoted backslash is a
psql
meta-command that is processed by
psql
- itself. These commands help make
+ itself. These commands make
psql more useful for administration or
scripting. Meta-commands are often called slash or backslash commands.
aligned format is the standard, human-readable,
- nicely formatted text output that is default.
+ nicely formatted text output; this is the default.
Escapes to a separate Unix shell or executes the Unix command
command. The
- arguments are not further interpreted, the shell will see them
+ arguments are not further interpreted; the shell will see them
as-is.
number of them. A number of these variables are treated specially
by
psql. They indicate certain option
settings that can be changed at run time by altering the value of
- the variable or represent some state of the application. Although
+ the variable or that represent some state of the application. Although
you can use these variables for any other purpose, this is not
recommended, as the program behavior might grow really strange
really quickly. By convention, all specially treated variables
Since colons can legally appear in SQL commands, an apparent attempt
at interpolation (such as :name,
:'name', or :"name") is not
- changed unless the named variable is currently set. In any case you
+ changed unless the named variable is currently set. In any case, you
can escape a colon with a backslash to protect it from substitution.
(The colon syntax for variables is standard
SQL for
embedded query languages, such as
ECPG.