{"Entry":{"collection":"tool","key":"pg-restore","name":"pg_restore","aliases":["pg_restore"],"metadata":{"aliases":["pg_restore"],"category":"Client applications","content_hash":"1ee014b8132249ec873b1c199a0ef3c7d86e5a9b14605318cd42aabcefe80257","derived_content_hash":"a33dafaca82c623d4eb7f5cff7a4f2387335659b67fb82080539a3d05b481960","documentation_refresh":{"batch":"20261113","original_source_rev":"","versions":{"14":"14.25","15":"15.20","16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"imported_at":"2026-09-30T00:40:34.363153+08:00","name":"pg_restore","name_zh":"","slug":"pg-restore","summary":"pg_restore — restore a PostgreSQL database from an archive file created by pg_dump"}},"Definition":{"Collection":"tool","Key":"pg-restore","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"pg-restore","SourceRevision":"1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915","Facts":{"comparison_data":{"environment":[{"description":"Default connection parameters","name":"PGHOST PGOPTIONS PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"options":[{"description":"Restore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive. This option is similar to, but for historical reasons not identical to, specifying --section=data .","names":["-a","--data-only"],"signature":"-a --data-only"},{"description":"Before restoring database objects, issue commands to DROP all the objects that will be restored. This option is useful for overwriting an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported, unless --if-exists is also specified.","names":["-c","--clean"],"signature":"-c --clean"},{"description":"Create the database before restoring into it. If --clean is also specified, drop and recreate the target database before connecting to it. With --create , pg_restore also restores the database's comment if any, and any configuration variable settings that are specific to this database, that is, any ALTER DATABASE ... SET ... and ALTER ROLE ... IN DATABASE ... SET ... commands that mention this database. Access privileges for the database itself are also restored, unless --no-acl is specified. When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is restored into the database name that appears in the archive.","names":["-C","--create"],"signature":"-C --create"},{"description":"Connect to database dbname and restore directly into the database. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.","names":["-d dbname","--dbname= dbname"],"signature":"-d dbname --dbname= dbname"},{"description":"Exit if an error is encountered while sending SQL commands to the database. The default is to continue and to display a count of errors at the end of the restoration.","names":["-e","--exit-on-error"],"signature":"-e --exit-on-error"},{"description":"Specify output file for generated script, or for the listing when used with -l . Use - for stdout .","names":["-f filename","--file= filename"],"signature":"-f filename --file= filename"},{"description":"Specify format of the archive. It is not necessary to specify the format, since pg_restore will determine the format automatically. If specified, it can be one of the following: c custom The archive is in the custom format of pg_dump . d directory The archive is a directory archive. t tar The archive is a tar archive.","names":["-F format","--format= format"],"signature":"-F format --format= format"},{"description":"Restore definition of named index only. Multiple indexes may be specified with multiple -I switches.","names":["-I index","--index= index"],"signature":"-I index --index= index"},{"description":"Run the most time-consuming steps of pg_restore — those that load data, create indexes, or create constraints — concurrently, using up to number-of-jobs concurrent sessions. This option can dramatically reduce the time to restore a large database to a server running on a multiprocessor machine. This option is ignored when emitting a script rather than connecting directly to a database server. Each job is one process or one thread, depending on the operating system, and uses a separate connection to the server. The optimal value for this option depends on the hardware setup of the server, of the client, and of the network. Factors include the number of CPU cores and the disk setup. A 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 decreased performance because of thrashing. Only the custom and directory archive formats are supported with this option. The input must be a regular file or directory (not, for example, a pipe or standard input). Also, multiple jobs cannot be used together with the option --single-transaction .","names":["-j number-of-jobs","--jobs= number-of-jobs"],"signature":"-j number-of-jobs --jobs= number-of-jobs"},{"description":"List the table of contents of the archive. The output of this operation can be used as input to the -L option. Note that if filtering switches such as -n or -t are used with -l , they will restrict the items listed.","names":["-l","--list"],"signature":"-l --list"},{"description":"Restore only those archive elements that are listed in list-file , and restore them in the order they appear in the file. Note that if filtering switches such as -n or -t are used with -L , they will further restrict the items restored. list-file is normally created by editing the output of a previous -l operation. Lines can be moved or removed, and can also be commented out by placing a semicolon ( ; ) at the start of the line. See below for examples.","names":["-L list-file","--use-list= list-file"],"signature":"-L list-file --use-list= list-file"},{"description":"Restore only objects that are in the named schema. Multiple schemas may be specified with multiple -n switches. This can be combined with the -t option to restore just a specific table.","names":["-n schema","--schema= schema"],"signature":"-n schema --schema= schema"},{"description":"Do not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple -N switches. When both -n and -N are given for the same schema name, the -N switch wins and the schema is excluded.","names":["-N schema","--exclude-schema= schema"],"signature":"-N schema --exclude-schema= schema"},{"description":"Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O , any user name can be used for the initial connection, and this user will own all the created objects.","names":["-O","--no-owner"],"signature":"-O --no-owner"},{"description":"Restore the named function only. Be careful to spell the function name and arguments exactly as they appear in the dump file's table of contents. Multiple functions may be specified with multiple -P switches.","names":["-P function-name(argtype [, ...])","--function= function-name(argtype [, ...])"],"signature":"-P function-name(argtype [, ...]) --function= function-name(argtype [, ...])"},{"description":"This option is obsolete but still accepted for backwards compatibility.","names":["-R","--no-reconnect"],"signature":"-R --no-reconnect"},{"description":"Restore only the schema (data definitions), not data, to the extent that schema entries are present in the archive. This option cannot be used with --data-only or --statistics-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data --no-statistics . (Do not confuse this with the --schema option, which uses the word “ schema ” in a different meaning.)","names":["-s","--schema-only"],"signature":"-s --schema-only"},{"description":"Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used.","names":["-S username","--superuser= username"],"signature":"-S username --superuser= username"},{"description":"Restore definition and/or data of only the named table. For this purpose, “ table ” includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. This option can be combined with the -n option to specify table(s) in a particular schema. Note When -t is specified, pg_restore makes no attempt to restore any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that a specific-table restore into a clean database will succeed. Note This flag does not behave identically to the -t flag of pg_dump . There is not currently any provision for wild-card matching in pg_restore , nor can you include a schema name within its -t . And, while pg_dump 's -t flag will also dump subsidiary objects (such as indexes) of the selected table(s), pg_restore 's -t flag does not include such subsidiary objects. Note In versions prior to PostgreSQL 9.6, this flag matched only tables, not any other type of relation.","names":["-t table","--table= table"],"signature":"-t table --table= table"},{"description":"Restore named trigger only. Multiple triggers may be specified with multiple -T switches.","names":["-T trigger","--trigger= trigger"],"signature":"-T trigger --trigger= trigger"},{"description":"Specifies verbose mode. This will cause pg_restore to output detailed object comments and start/stop times to the output file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.","names":["-v","--verbose"],"signature":"-v --verbose"},{"description":"Print the pg_restore version and exit.","names":["-V","--version"],"signature":"-V --version"},{"description":"Prevent restoration of access privileges (grant/revoke commands).","names":["-x","--no-privileges","--no-acl"],"signature":"-x --no-privileges --no-acl"},{"description":"Execute the restore as a single transaction (that is, wrap the emitted commands in BEGIN / COMMIT ). This ensures that either all the commands complete successfully, or no changes are applied. This option implies --exit-on-error .","names":["-1","--single-transaction"],"signature":"-1 --single-transaction"},{"description":"This option is relevant only when performing a restore without schema. It instructs pg_restore to execute commands to temporarily disable triggers on the target tables while the data is restored. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data restore. Presently, the commands emitted for --disable-triggers must be done as superuser. So you should also specify a superuser name with -S or, preferably, run pg_restore as a PostgreSQL superuser.","names":["--disable-triggers"],"signature":"--disable-triggers"},{"description":"This option is relevant only when restoring the contents of a table which has row security. By default, pg_restore will set row_security to off, to ensure that all data is restored in to the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_restore to set row_security to on instead, allowing the user to attempt to restore the contents of the table with row security enabled. This might still fail if the user does not have the right to insert the rows from the dump into the table. Note that this option currently also requires the dump be in INSERT format, as COPY FROM does not support row security.","names":["--enable-row-security"],"signature":"--enable-row-security"},{"description":"Specify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as -n / --schema for including objects in schemas, -N / --exclude-schema for excluding objects in schemas, -P / --function for restoring named functions, -I / --index for restoring named indexes, -t / --table for restoring named tables or -T / --trigger for restoring triggers. To read from STDIN , use - as the filename. The --filter option can be specified in conjunction with the above listed options for including or excluding objects, and can also be specified more than once for multiple filter files. The file lists one database pattern per row, with the following format: { include | exclude } { function | index | schema | table | trigger } PATTERN The first keyword specifies whether the objects matched by the pattern are to be included or excluded. The second keyword specifies the type of object to be filtered using the pattern: function : functions, works like the -P / --function option. This keyword can only be used with the include keyword. index : indexes, works like the -I / --index option. This keyword can only be used with the include keyword. schema : schemas, works like the -n / --schema and -N / --exclude-schema options. table : tables, works like the -t / --table option. This keyword can only be used with the include keyword. trigger : triggers, works like the -T / --trigger option. This keyword can only be used with the include keyword. Lines starting with # are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See Patterns for how to perform quoting in patterns.","names":["--filter= filename"],"signature":"--filter= filename"},{"description":"Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses “ does not exist ” errors that might otherwise be reported. This option is not valid unless --clean is also specified.","names":["--if-exists"],"signature":"--if-exists"},{"description":"Do not output commands to restore comments, even if the archive contains them.","names":["--no-comments"],"signature":"--no-comments"},{"description":"Do not output commands to restore data, even if the archive contains them.","names":["--no-data"],"signature":"--no-data"},{"description":"By default, table data is restored even if the creation command for the table failed (e.g., because it already exists). With this option, data for such a table is skipped. This behavior is useful if the target database already contains the desired table contents. For example, auxiliary tables for PostgreSQL extensions such as PostGIS might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them. This option is effective only when restoring directly into a database, not when producing SQL script output.","names":["--no-data-for-failed-tables"],"signature":"--no-data-for-failed-tables"},{"description":"Do not output commands to restore row security policies, even if the archive contains them.","names":["--no-policies"],"signature":"--no-policies"},{"description":"Do not output commands to restore publications, even if the archive contains them.","names":["--no-publications"],"signature":"--no-publications"},{"description":"Do not output commands to restore schema (data definitions), even if the archive contains them.","names":["--no-schema"],"signature":"--no-schema"},{"description":"Do not output commands to restore security labels, even if the archive contains them.","names":["--no-security-labels"],"signature":"--no-security-labels"},{"description":"Do not output commands to restore statistics, even if the archive contains them.","names":["--no-statistics"],"signature":"--no-statistics"},{"description":"Do not output commands to restore subscriptions, even if the archive contains them.","names":["--no-subscriptions"],"signature":"--no-subscriptions"},{"description":"Do not output commands to select table access methods. With this option, all objects will be created with whichever table access method is the default during restore.","names":["--no-table-access-method"],"signature":"--no-table-access-method"},{"description":"Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.","names":["--no-tablespaces"],"signature":"--no-tablespaces"},{"description":"Use the provided string as the psql \\restrict key in the dump output. This can only be specified for SQL script output, i.e., when the --file option is used. If no restrict key is specified, pg_restore will generate a random one as needed. Keys may contain only alphanumeric characters. This option is primarily intended for testing purposes and other scenarios that require repeatable output (e.g., comparing dump files). It is not recommended for general use, as a malicious server with advance knowledge of the key may be able to inject arbitrary code that will be executed on the machine that runs psql with the dump output.","names":["--restrict-key= restrict_key"],"signature":"--restrict-key= restrict_key"},{"description":"Only restore the named section. The section name can be pre-data , data , or post-data . This option can be specified more than once to select multiple sections. The default is to restore all sections. The data section contains actual table data as well as large-object definitions. Post-data items consist of definitions of indexes, triggers, rules and constraints other than validated check constraints. Pre-data items consist of all other data definition items.","names":["--section= sectionname"],"signature":"--section= sectionname"},{"description":"Output commands to restore statistics, if the archive contains them. This is the default.","names":["--statistics"],"signature":"--statistics"},{"description":"Restore only the statistics, not schema (data definitions) or data.","names":["--statistics-only"],"signature":"--statistics-only"},{"description":"Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the file to be restored.","names":["--strict-names"],"signature":"--strict-names"},{"description":"Execute the restore as a series of transactions, each processing up to N database objects. This option implies --exit-on-error . --transaction-size offers an intermediate choice between the default behavior (one transaction per SQL command) and -1 / --single-transaction (one transaction for all restored objects). While --single-transaction has the least overhead, it may be impractical for large databases because the transaction will take a lock on each restored object, possibly exhausting the server's lock table space. Using --transaction-size with a size of a few thousand objects offers nearly the same performance benefits while capping the amount of lock table space needed.","names":["--transaction-size= N"],"signature":"--transaction-size= N"},{"description":"Output SQL-standard SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to determine object ownership. This makes the dump more standards-compatible, but depending on the history of the objects in the dump, might not restore properly.","names":["--use-set-session-authorization"],"signature":"--use-set-session-authorization"},{"description":"Show help about pg_restore command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help"},{"description":"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 PGHOST environment variable, if set, else a Unix domain socket connection is attempted.","names":["-h host","--host= host"],"signature":"-h host --host= host"},{"description":"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.","names":["-p port","--port= port"],"signature":"-p port --port= port"},{"description":"User name to connect as.","names":["-U username","--username= username"],"signature":"-U username --username= username"},{"description":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.","names":["-w","--no-password"],"signature":"-w --no-password"},{"description":"Force pg_restore to prompt for a password before connecting to a database. This option is never essential, since pg_restore will automatically prompt for a password if the server demands password authentication. However, pg_restore will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.","names":["-W","--password"],"signature":"-W --password"},{"description":"Specifies a role name to be used to perform the restore. This option causes pg_restore to issue a SET ROLE rolename command after connecting to the database. It is useful when the authenticated user (specified by -U ) lacks privileges needed by pg_restore , but can switch to a role with the required rights. Some installations have a policy against logging in directly as a superuser, and use of this option allows restores to be performed without violating the policy.","names":["--role= rolename"],"signature":"--role= rolename"}],"synopsis":["pg_restore [ connection-option ...] [ option ...] [ filename ]"]},"comparison_hash":"bd6f4ae67c44e7910aa300beb77d5bbe563ed23a586f2889963b7389840c0f97","description":["pg_restore — restore a PostgreSQL database from an archive file created by pg_dump"],"description_zh":"pg_restore — 从由 pg_dump 创建的归档文件恢复 PostgreSQL 数据库","description_zh_html":"\u003cdiv class=\"refentry\" id=\"APP-PGRESTORE\"\u003e\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\u003cdiv class=\"refnamediv\"\u003e\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\u003cp\u003epg_restore — \n   从由 \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e 创建的归档文件恢复 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 数据库\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsynopsisdiv\"\u003e\u003ch2\u003e大纲\u003c/h2\u003e\u003cdiv class=\"cmdsynopsis\"\u003e\u003cp id=\"id-1.9.4.19.4.1\"\u003e\u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003econnection-option\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DESCRIPTION\"\u003e\u003ch2\u003e描述\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 是一个用于从 \u003ca class=\"xref\" href=\"/zh/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e 以非纯文本格式创建的归档中恢复 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e\n   数据库的工具。它会发出必要的命令，将数据库重建为保存时的状态。归档文件还允许 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 有选择地恢复其中的内容，甚至在恢复前重新排列各项的顺序。归档文件被设计为可跨体系结构移植。\n  \u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 可以以两种模式运行。如果指定了数据库名，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 就会连接到该数据库，并将归档内容直接恢复到数据库中。否则，它会创建一个脚本，其中包含重建数据库所需的 SQL 命令，并将其写入文件或标准输出。这种脚本输出等价于 \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e 的纯文本输出格式。因此，一些控制输出的选项与 \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e 的选项相对应。\n  \u003c/p\u003e\u003cp\u003e\n   显然，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 无法恢复归档文件中不存在的信息。例如，如果归档是使用\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e将数据转储为 \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e 命令\u003c/span\u003e”\u003c/span\u003e选项生成的，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 就不能使用 \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e 语句装载数据。\n  \u003c/p\u003e\u003cdiv class=\"warning\"\u003e\u003ch3 class=\"title\"\u003e警告\u003c/h3\u003e\u003cp\u003e\n    恢复转储会导致目标端执行由源超级用户选择的任意代码。部分转储和部分恢复并不会限制这一点。如果源超级用户不可信，则必须在恢复前检查转储得到的\n    SQL 语句。非纯文本转储可以使用 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 的\n    \u003ccode class=\"option\"\u003e--file\u003c/code\u003e 选项进行检查。注意，运行转储和恢复的客户端无需信任源或目标超级用户。\n   \u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-OPTIONS\"\u003e\u003ch2\u003e选项\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 接受下列命令行参数。\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-1\"\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定要恢复的归档文件所在位置（对于目录格式归档则为目录）。如果未指定，则使用标准输入。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-2\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-a\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复数据，不恢复模式（数据定义）或统计信息。如果归档中包含，则会恢复表数据、大对象和序列值。\n       \u003c/p\u003e\u003cp\u003e\n        此选项类似于指定 \u003ccode class=\"option\"\u003e--section=data\u003c/code\u003e，但出于历史原因，两者并不完全相同。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-3\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--clean\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在恢复数据库对象之前，发出 \u003ccode class=\"command\"\u003eDROP\u003c/code\u003e 命令以删除将要恢复的所有对象。此选项适用于覆盖现有数据库。如果目标数据库中有任何对象不存在，则会报告可忽略的错误消息，除非同时指定了 \u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-4\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在向其中恢复之前先创建数据库。如果同时指定了 \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e，则会在连接到目标数据库之前先删除并重新创建它。\n       \u003c/p\u003e\u003cp\u003e\n        使用 \u003ccode class=\"option\"\u003e--create\u003c/code\u003e 时，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n        还会恢复数据库的注释（如果有）以及该数据库专有的任何配置变量设置，也就是任何提到该数据库的\n        \u003ccode class=\"command\"\u003eALTER DATABASE ... SET ...\u003c/code\u003e 和\n        \u003ccode class=\"command\"\u003eALTER ROLE ... IN DATABASE ... SET ...\u003c/code\u003e 命令。除非指定了 \u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e，还会恢复数据库本身的访问权限。\n       \u003c/p\u003e\u003cp\u003e\n        使用此选项时，由 \u003ccode class=\"option\"\u003e-d\u003c/code\u003e 指定的数据库仅用于发出初始的\n        \u003ccode class=\"command\"\u003eDROP DATABASE\u003c/code\u003e 和 \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e 命令。所有数据都会恢复到以归档中记录的名称命名的数据库。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-5\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        连接到数据库 \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e，并直接恢复到该数据库中。\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e 可以是一个\u003ca class=\"link\" href=\"/zh/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. 连接字符串\"\u003e连接字符串\u003c/a\u003e。如果是这样，连接字符串参数会覆盖任何冲突的命令行选项。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-6\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        如果在向数据库发送 SQL 命令时遇到错误，则退出。默认行为是继续执行，并在恢复结束时显示错误计数。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-7\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定生成脚本的输出文件，或者在与 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e 一起使用时指定列表输出文件。使用 \u003ccode class=\"literal\"\u003e-\u003c/code\u003e 表示 \u003cspan class=\"systemitem\"\u003estdout\u003c/span\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-8\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F \u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--format=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e指定归档格式。不必指定格式，因为 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会自动确定格式。如果指定，可以是以下格式之一：\u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-9\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ec\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecustom\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           归档采用 \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e 的自定义格式。\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-10\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ed\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003edirectory\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           归档是目录格式归档。\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-11\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etar\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           归档是 \u003ccode class=\"command\"\u003etar\u003c/code\u003e 归档。\n          \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-12\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-I \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--index=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复指定名称的索引的定义。可以通过多次指定 \u003ccode class=\"option\"\u003e-I\u003c/code\u003e 来恢复多个索引。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-13\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-j \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--jobs=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 中最耗时的步骤，也就是装载数据、创建索引或创建约束，最多使用 \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\n        个并发会话并行执行。此选项可以显著缩短将大型数据库恢复到运行在多处理器机器上的服务器所需的时间。当生成脚本而不是直接连接到数据库服务器时，此选项会被忽略。\n       \u003c/p\u003e\u003cp\u003e\n        每个作业都是一个进程或一个线程，具体取决于操作系统，并使用一个到服务器的独立连接。\n       \u003c/p\u003e\u003cp\u003e\n        此选项的最佳取值取决于服务器、客户端和网络的硬件配置。影响因素包括 CPU 核心数和磁盘配置。一个较好的起点是服务器上的 CPU 核心数，但在很多情况下，更大的值也可能带来更快的恢复速度。当然，取值过高会因为频繁争用而导致性能下降。\n       \u003c/p\u003e\u003cp\u003e\n        只有自定义格式和目录格式归档支持此选项。输入必须是常规文件或目录（例如不能是管道或标准输入）。另外，多个作业不能与\n        \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e 选项一起使用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-14\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--list\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        列出归档的目录内容（table of contents）。此操作的输出可用作 \u003ccode class=\"option\"\u003e-L\u003c/code\u003e 选项的输入。请注意，如果在 \u003ccode class=\"option\"\u003e-l\u003c/code\u003e 中使用 \u003ccode class=\"option\"\u003e-n\u003c/code\u003e 或 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e\n        等过滤开关，它们会限制被列出的项目。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-15\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-list=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复在 \u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e 中列出的归档元素，并按它们在文件中出现的顺序进行恢复。请注意，如果在 \u003ccode class=\"option\"\u003e-L\u003c/code\u003e 中使用\n        \u003ccode class=\"option\"\u003e-n\u003c/code\u003e 或 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 等过滤开关，它们还会进一步限制被恢复的项目。\n       \u003c/p\u003e\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e 通常是通过编辑先前\n        \u003ccode class=\"option\"\u003e-l\u003c/code\u003e 操作的输出来创建的。可以移动或删除行，也可以通过在行首放置分号（\u003ccode class=\"literal\"\u003e;\u003c/code\u003e）将其注释掉。示例见下文。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-16\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--schema=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复位于指定模式中的对象。可以通过多次指定 \u003ccode class=\"option\"\u003e-n\u003c/code\u003e 来指定多个模式。这可以与 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 选项结合使用，只恢复特定表。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-17\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exclude-schema=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不恢复位于指定模式中的对象。可以通过多次指定 \u003ccode class=\"option\"\u003e-N\u003c/code\u003e 来排除多个模式。\n       \u003c/p\u003e\u003cp\u003e\n        当对同一模式名同时给出 \u003ccode class=\"option\"\u003e-n\u003c/code\u003e 和 \u003ccode class=\"option\"\u003e-N\u003c/code\u003e 时，\u003ccode class=\"option\"\u003e-N\u003c/code\u003e 优先，该模式会被排除。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-18\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-O\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-owner\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于设置对象所有权以匹配原始数据库的命令。默认情况下，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会发出 \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e 或\n        \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e 语句，为所创建的模式元素设置所有权。除非对数据库的初始连接由超级用户发起（或者由脚本中所有对象的同一所有者发起），否则这些语句会失败。使用 \u003ccode class=\"option\"\u003e-O\u003c/code\u003e 时，初始连接可以使用任意用户名，并且该用户将拥有所有创建的对象。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-19\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P \u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--function=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复指定函数。请务必按转储文件目录中显示的形式准确拼写函数名和参数。可以通过多次指定 \u003ccode class=\"option\"\u003e-P\u003c/code\u003e 来恢复多个函数。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-20\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-reconnect\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        这个选项已经过时，但仍然被接受以保持向后兼容性。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-21\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--schema-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复模式（数据定义），不恢复数据，前提是归档中存在模式条目。\n       \u003c/p\u003e\u003cp\u003e\n        此选项不能与 \u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e 或 \u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e 一起使用。它类似于指定\n        \u003ccode class=\"option\"\u003e--section=pre-data --section=post-data --no-statistics\u003c/code\u003e，但由于历史原因并不完全相同。\n       \u003c/p\u003e\u003cp\u003e\n        （不要把它与 \u003ccode class=\"option\"\u003e--schema\u003c/code\u003e 选项混淆，后者中的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eschema\u003c/span\u003e”\u003c/span\u003e一词含义不同。）\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-22\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--superuser=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定在禁用触发器时要使用的超级用户用户名。仅当使用\n        \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e 时才相关。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-23\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--table=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复指定表的定义和/或数据。这里的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e表\u003c/span\u003e”\u003c/span\u003e包括视图、物化视图、序列和外部表。可以通过多次指定 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 来选择多个表。此选项可以与 \u003ccode class=\"option\"\u003e-n\u003c/code\u003e 选项结合使用，以指定特定模式中的表。\n       \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n         当指定 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 时，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n         不会尝试恢复所选表可能依赖的任何其他数据库对象。因此，不能保证将特定表恢复到一个空数据库中一定会成功。\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n         此标志与 \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e 的 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 标志并不完全相同。\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 目前不支持通配符匹配，也不能在其\n         \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 中包含模式名。而且，虽然 \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\n         的 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 标志也会转储所选表的附属对象（例如索引），\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 的 \u003ccode class=\"option\"\u003e-t\u003c/code\u003e 标志并不包括这些附属对象。\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n         在 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6 之前的版本中，此标志只匹配表，不匹配其他任何类型的关系。\n        \u003c/p\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-24\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--trigger=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复指定名称的触发器。可以通过多次指定 \u003ccode class=\"option\"\u003e-T\u003c/code\u003e 来恢复多个触发器。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-25\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定详细模式。这会使 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 将详细的对象注释和开始/停止时间输出到输出文件，并将进度消息输出到标准错误。重复此选项会使标准错误中出现额外的调试级消息。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-26\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        打印 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 的版本并退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-27\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-privileges\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        阻止恢复访问权限（\u003ccode class=\"command\"\u003eGRANT\u003c/code\u003e/\u003ccode class=\"command\"\u003eREVOKE\u003c/code\u003e 命令）。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-28\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-1\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将恢复作为单个事务执行（也就是把发出的命令包裹在\n        \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e 中）。这可确保要么所有命令都成功完成，要么不应用任何更改。此选项隐含 \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-29\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        此选项仅在执行不包含模式的恢复时才相关。它会指示\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 在恢复数据期间发出命令，临时禁用目标表上的触发器。如果你不希望在恢复数据期间触发表上的引用完整性检查或其他触发器，请使用此选项。\n       \u003c/p\u003e\u003cp\u003e\n        目前，为 \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e 发出的命令必须以超级用户身份执行。因此，你还应通过 \u003ccode class=\"option\"\u003e-S\u003c/code\u003e 指定超级用户用户名，或者更好的是，直接以\n        \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 超级用户身份运行 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-30\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--enable-row-security\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        此选项仅在恢复启用了行安全性的表内容时才相关。默认情况下，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会将 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e 设置为 off，以确保所有数据都能恢复到表中。如果用户没有足够的权限绕过行安全性，就会抛出错误。此参数会指示 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 改为将 \u003ca class=\"xref\" href=\"/zh/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e 设置为 on，从而允许用户尝试在启用行安全性的情况下恢复表内容。如果用户无权将转储中的行插入该表，这仍然可能失败。\n       \u003c/p\u003e\u003cp\u003e\n        请注意，此选项当前还要求转储采用 \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e 格式，因为 \u003ccode class=\"command\"\u003eCOPY FROM\u003c/code\u003e 不支持行安全性。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-31\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--filter=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定一个文件名，从中读取恢复时要排除或包含的对象匹配模式。这些模式按照与下列选项相同的规则解释：\u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e 用于包含某个模式中的对象，\u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e 用于排除某个模式中的对象，\u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e 用于恢复指定函数，\u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e 用于恢复指定索引，\u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e 用于恢复指定表，以及 \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e 用于恢复触发器。要从 \u003ccode class=\"literal\"\u003eSTDIN\u003c/code\u003e 读取，请使用 \u003ccode class=\"filename\"\u003e-\u003c/code\u003e 作为文件名。\u003ccode class=\"option\"\u003e--filter\u003c/code\u003e 选项可以与上面列出的包含或排除对象的选项结合使用，也可以为了指定多个过滤文件而多次给出。\n       \u003c/p\u003e\u003cp\u003e\n        该文件每行列出一个对象匹配模式，格式如下：\n\u003c/p\u003e\u003cpre class=\"synopsis\"\u003e\n{ include | exclude } { function | index | schema | table | trigger } \u003cem class=\"replaceable\"\u003e\u003ccode\u003ePATTERN\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        第一个关键字指定是包含还是排除与模式匹配的对象。第二个关键字指定要用该模式过滤的对象类型：\n        \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\" style=\"list-style-type: disc; \"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003efunction\u003c/code\u003e：函数，作用与\n           \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e 选项相同。该关键字只能与 \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e 关键字一起使用。\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003eindex\u003c/code\u003e：索引，作用与\n           \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e 选项相同。该关键字只能与 \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e 关键字一起使用。\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003eschema\u003c/code\u003e：模式，作用与\n           \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e 和\n           \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e 选项相同。\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003etable\u003c/code\u003e：表，作用与\n           \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e 选项相同。该关键字只能与 \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e 关键字一起使用。\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003etrigger\u003c/code\u003e：触发器，作用与\n           \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e 选项相同。该关键字只能与 \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e 关键字一起使用。\n          \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        以 \u003ccode class=\"literal\"\u003e#\u003c/code\u003e 开头的行被视为注释并忽略。注释也可以放在对象匹配模式行之后。空白行同样会被忽略。有关如何在匹配模式中加引号，请参见\u003ca class=\"xref\" href=\"/zh/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"模式\"\u003e模式\u003c/a\u003e。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-32\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        使用 \u003ccode class=\"literal\"\u003eDROP ... IF EXISTS\u003c/code\u003e 命令在\n        \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e 模式下删除对象。这会抑制原本可能报告的\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edoes not exist\u003c/span\u003e”\u003c/span\u003e错误信息。除非同时指定了 \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e，否则此选项无效。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-33\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-comments\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复注释的命令，即使归档中包含注释。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-34\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复数据的命令，即使归档中包含数据。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-35\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-for-failed-tables\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        默认情况下，即使表的创建命令失败（例如因为表已经存在），表数据仍然会被恢复。使用此选项时，这类表的数据会被跳过。如果目标数据库已经包含所需的表内容，这种行为会很有用。例如，\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 扩展（如 \u003cspan class=\"productname\"\u003ePostGIS\u003c/span\u003e）的辅助表可能已经装载到目标数据库中；指定此选项可以防止向这些表装载重复或过时的数据。\n       \u003c/p\u003e\u003cp\u003e\n        此选项仅在直接恢复到数据库时有效，而在生成 SQL 脚本输出时无效。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-36\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-policies\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复行安全性策略的命令，即使归档中包含它们。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-37\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-publications\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复发布的命令，即使归档中包含它们。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-38\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-schema\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复模式（数据定义）的命令，即使归档中包含它们。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-39\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-security-labels\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复安全标签的命令，即使归档中包含它们。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-40\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-statistics\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复统计信息的命令，即使归档中包含它们。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-41\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-subscriptions\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于恢复订阅的命令，即使归档中包含它们。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-42\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-table-access-method\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于选择表访问方法的命令。使用此选项时，所有对象在恢复时都会使用当时默认的表访问方法创建。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-43\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-tablespaces\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        不输出用于选择表空间的命令。使用此选项时，所有对象在恢复时都会创建在当时默认的表空间中。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-44\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--restrict-key=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        在转储输出中使用提供的字符串作为 \u003cspan class=\"application\"\u003epsql\u003c/span\u003e\n\u003ccode class=\"command\"\u003e\\restrict\u003c/code\u003e 键。这只能用于 SQL 脚本输出，也就是使用\n        \u003ccode class=\"option\"\u003e--file\u003c/code\u003e 选项时。如果未指定该键，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会按需随机生成一个。键只能包含字母数字字符。\n       \u003c/p\u003e\u003cp\u003e\n        此选项主要用于测试以及其他需要可重复输出的场景（例如比较转储文件）。一般不建议使用它，因为若恶意服务器事先知道该键，可能能够注入任意代码，并在运行 \u003cspan class=\"application\"\u003epsql\u003c/span\u003e 处理转储输出的机器上执行。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-45\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--section=\u003cem class=\"replaceable\"\u003e\u003ccode\u003esectionname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n          仅恢复指定部分。部分名称可以是 \u003ccode class=\"option\"\u003epre-data\u003c/code\u003e、\u003ccode class=\"option\"\u003edata\u003c/code\u003e\n          或 \u003ccode class=\"option\"\u003epost-data\u003c/code\u003e。可以多次指定此选项来选择多个部分。默认是恢复所有部分。\n         \u003c/p\u003e\u003cp\u003e\n          数据部分包含实际的表数据以及大对象定义。post-data 部分由索引、触发器、规则以及除已验证检查约束之外的约束定义组成。pre-data 部分则由所有其他数据定义项组成。\n         \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-46\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        如果归档中包含统计信息，则输出用于恢复统计信息的命令。这是默认行为。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-47\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        仅恢复统计信息，不恢复模式（数据定义）或数据。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-48\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--strict-names\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        要求每个模式限定符（\u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e）和表限定符（\u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e）至少匹配待恢复文件中的一个模式/表。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-49\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--transaction-size=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        将恢复作为一系列事务执行，每个事务最多处理\n        \u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e 个数据库对象。此选项隐含\n        \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e。\n       \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e 在默认行为（每条 SQL 命令一个事务）与\n        \u003ccode class=\"option\"\u003e-1\u003c/code\u003e/\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e（所有恢复对象共用一个事务）之间提供了一个折中选择。虽然 \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e 的额外开销最小，但对于大型数据库来说可能并不现实，因为该事务会在每个恢复对象上获取锁，从而可能耗尽服务器的锁表空间。使用 \u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e 并将大小设为几千个对象，可以在限制所需锁表空间的同时，获得几乎相同的性能收益。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-50\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-set-session-authorization\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        输出符合 SQL 标准的 \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e 命令，而不是使用 \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e 命令来确定对象所有权。这样会使转储结果更符合标准，但根据转储中对象的历史，可能无法正确恢复。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-51\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        显示关于 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 命令行参数的帮助信息，并退出。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 还接受下列用于连接参数的命令行参数：\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-52\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定服务器所在机器的主机名。如果值以斜杠开头，则被用作 Unix 域套接字的目录。默认值取自 \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e 环境变量（如果已设置），否则尝试使用 Unix 域套接字连接。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-53\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定服务器正在监听连接的 TCP 端口，或本地 Unix 域套接字文件扩展名。默认值取自 \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e 环境变量（如果已设置），否则使用编译时默认值。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-54\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        用于连接的用户名。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-55\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        绝不发出密码提示。如果服务器要求密码认证，而又无法通过\n        \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e 文件等其他方式获得密码，则连接尝试将失败。在没有用户在场输入密码的批处理作业和脚本中，此选项很有用。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-56\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        强制 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 在连接数据库之前提示输入密码。\n       \u003c/p\u003e\u003cp\u003e\n        此选项实际上并非必需，因为如果服务器要求密码认证，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会自动提示输入密码。不过，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会浪费一次连接尝试来发现服务器需要密码。在某些情况下，键入 \u003ccode class=\"option\"\u003e-W\u003c/code\u003e 以避免这一次额外的连接尝试是值得的。\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-57\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--role=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        指定执行恢复时要使用的角色名。此选项会使 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n        在连接数据库后发出 \u003ccode class=\"command\"\u003eSET ROLE\u003c/code\u003e\n\u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e 命令。当已认证用户（由 \u003ccode class=\"option\"\u003e-U\u003c/code\u003e 指定）缺少\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 所需的权限，但可以切换到具有所需权限的角色时，此选项会很有用。有些安装环境禁止直接以超级用户登录，而使用此选项可以在不违反该策略的情况下执行恢复。\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.7\"\u003e\u003ch2\u003e环境\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-58\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGOPTIONS\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e\u003cbr/\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      默认连接参数\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt id=\"ZH18-AUTO-PG_RESTORE-VARLISTENTRY-59\"\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e \u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      指定诊断消息是否使用颜色。可选值为\n      \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e、\u003ccode class=\"literal\"\u003eauto\u003c/code\u003e 和\n      \u003ccode class=\"literal\"\u003enever\u003c/code\u003e。\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n   与大多数其他 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 工具一样，该工具也使用\n   \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e 支持的环境变量（见\u003ca class=\"xref\" href=\"/zh/docs/18/libpq-envars.html\" title=\"32.15. 环境变量\"\u003e第 32.15 节\u003c/a\u003e）。但是，当未提供数据库名时，它不会读取 \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e。\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DIAGNOSTICS\"\u003e\u003ch2\u003e诊断\u003c/h2\u003e\u003cp\u003e\n   当使用 \u003ccode class=\"option\"\u003e-d\u003c/code\u003e 选项指定直接数据库连接时，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会在内部执行 \u003cacronym class=\"acronym\"\u003eSQL\u003c/acronym\u003e 语句。如果运行 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 时遇到问题，请确保你能够使用例如 \u003ca class=\"xref\" href=\"/zh/docs/18/app-psql.html\" title=\"psql\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e 从该数据库中查询信息。此外，\u003cspan class=\"application\"\u003elibpq\u003c/span\u003e 前端库使用的任何默认连接设置和环境变量也都会生效。\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-NOTES\"\u003e\u003ch2\u003e注解\u003c/h2\u003e\u003cp\u003e\n   如果你的安装在 \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e 数据库中有任何本地添加内容，请务必将 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 的输出装载到一个真正空的数据库中；否则很可能会因为这些附加对象的重复定义而报错。要创建一个不带任何本地添加内容的空数据库，应从 \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e 而不是 \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e 复制，例如：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\nCREATE DATABASE foo WITH TEMPLATE template0;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 的局限性详述如下。\n\n   \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\" style=\"list-style-type: disc; \"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n      当把数据恢复到一个预先存在的表中，并且使用了\n      \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e 选项时，\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 会在插入数据前发出命令，禁用用户表上的触发器，然后在数据插入后再发出命令重新启用它们。如果恢复在中途停止，系统目录可能会处于错误状态。\n     \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 不能有选择地恢复大对象；例如，不能只恢复属于某个特定表的大对象。如果归档中包含大对象，那么要么所有大对象都会被恢复，要么在通过 \u003ccode class=\"option\"\u003e-L\u003c/code\u003e、\u003ccode class=\"option\"\u003e-t\u003c/code\u003e 或其他选项排除它们时一个也不会恢复。\n     \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   关于 \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e 的局限性的细节也可参见 \u003ca class=\"xref\" href=\"/zh/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e 文档。\n  \u003c/p\u003e\u003cp\u003e\n   默认情况下，如果转储文件中包含优化器统计信息，\u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e 会恢复它们。如果并非所有统计信息都已恢复，那么对每个已恢复的表执行 \u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e\n   可能会很有帮助，这样优化器就能获得有用的统计信息。更多信息见\u003ca class=\"xref\" href=\"/zh/docs/18/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3. 更新规划器统计信息\"\u003e第 24.1.3 节\u003c/a\u003e和\u003ca class=\"xref\" href=\"/zh/docs/18/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6. 自动清理守护进程\"\u003e第 24.1.6 节\u003c/a\u003e。\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-EXAMPLES\"\u003e\u003ch2\u003e示例\u003c/h2\u003e\u003cp\u003e\n   假设我们已经把一个名为 \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e 的数据库转储到一个自定义格式转储文件中：\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_dump -Fc mydb \u0026gt; db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   要删除该数据库并从转储中重新创建它：\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003edropdb mydb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -C -d postgres db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003ccode class=\"option\"\u003e-d\u003c/code\u003e 选项中指定的数据库可以是集簇中任何一个已存在的数据库；\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 只用它来为 \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e 发出\n   \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e 命令。使用 \u003ccode class=\"option\"\u003e-C\u003c/code\u003e 时，数据总是恢复到以转储文件中记录的名称命名的数据库。\n  \u003c/p\u003e\u003cp\u003e\n   要把该转储恢复到一个名为 \u003ccode class=\"literal\"\u003enewdb\u003c/code\u003e 的新数据库中：\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003ecreatedb -T template0 newdb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -d newdb db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   注意，这里我们不使用 \u003ccode class=\"option\"\u003e-C\u003c/code\u003e，而是直接连接到要恢复到的数据库。还要注意，我们是从 \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e 而不是 \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e\n   克隆这个新数据库，以确保它一开始是空的。\n  \u003c/p\u003e\u003cp\u003e\n   要重新排列数据库项的顺序，首先需要转储归档的目录：\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -l db.dump \u0026gt; db.list\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n   列表文件由一个头部和每个项各占一行的内容组成，例如：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\n;\n; Archive created at Mon Sep 14 13:55:39 2009\n;     dbname: DBDEMOS\n;     TOC Entries: 81\n;     Compression: 9\n;     Dump Version: 1.10-0\n;     Format: CUSTOM\n;     Integer: 4 bytes\n;     Offset: 8 bytes\n;     Dumped from database version: 8.3.5\n;     Dumped by pg_dump version: 8.3.8\n;\n;\n; Selected TOC Entries:\n;\n3; 2615 2200 SCHEMA - public pasha\n1861; 0 0 COMMENT - SCHEMA public pasha\n1862; 0 0 ACL - public pasha\n317; 1247 17715 TYPE public composite pasha\n319; 1247 25899 DOMAIN public domain0 pasha\n\u003c/pre\u003e\u003cp\u003e\n   分号表示一条注释的开始，而行首的数字表示分配给每个项的内部归档 ID。\n  \u003c/p\u003e\u003cp\u003e\n   文件中的行可以被注释掉、删除并重新排序。例如：\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e\n10; 145433 TABLE map_resolutions postgres\n;2; 145344 TABLE species postgres\n;4; 145359 TABLE nt_header postgres\n6; 145402 TABLE species_records postgres\n;8; 145416 TABLE ss_old postgres\n\u003c/pre\u003e\u003cp\u003e\n   可以将这样的文件作为 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 的输入，这样它就只会按该顺序恢复项 10 和 6：\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -L db.list db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.11\"\u003e\u003ch2\u003e另见\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/zh/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dumpall\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/zh/docs/18/app-psql.html\" title=\"psql\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e","documentation_revision":{"inputs":[{"file":"app-pgrestore.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"c1f6d0d6414421c81071e5fce256cb7d396f6e2922510643d0906263f2ef8dd4","version":"18.7"},{"file":"reference-client.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"a1c669b9a6dab81388171b696e61109033d96d2c4d5487219c77f62f14aecfa1","version":"18.7"},{"file":"app-pgrestore.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"f1f4d5449c539de962e72fdf1ae246b345e30a839a2c4416a396757d17f842aa","version":"18.7"},{"file":"reference-client.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"819e1b59b1a011bdaaff0c7cb9162348de1d0b34988a56179dc7ef1fee696a5a","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"},"environment":[{"description":"Default connection parameters","name":"PGHOST PGOPTIONS PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"facts":[{"label":"Documented executable","value":"pg_restore"},{"label":"Executable version","value":"18.7"},{"label":"Reference inventory","value":"Client applications"},{"label":"Option definition groups","value":"53"}],"facts_zh":[{"label":"手册中的可执行程序","value":"pg_restore"},{"label":"程序版本","value":"18.7"},{"label":"参考清单","value":"客户端程序"},{"label":"选项定义组","value":"53"}],"localization":{"documentation_release":"18.7","language":"en","source_language":"en","source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552","status":"same-version-reviewed-manual"},"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGRESTORE\"\u003e\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\u003cdiv class=\"refnamediv\"\u003e\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\u003cp\u003epg_restore — \n   restore a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an\n   archive file created by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsynopsisdiv\"\u003e\u003ch2\u003eSynopsis\u003c/h2\u003e\u003cdiv class=\"cmdsynopsis\"\u003e\u003cp id=\"id-1.9.4.19.4.1\"\u003e\u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003econnection-option\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DESCRIPTION\"\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e is a utility for restoring a\n   \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an archive\n   created by \u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e in one of the non-plain-text\n   formats.  It will issue the commands necessary to reconstruct the\n   database to the state it was in at the time it was saved.  The\n   archive files also allow \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to\n   be selective about what is restored, or even to reorder the items\n   prior to being restored. The archive files are designed to be\n   portable across architectures.\n  \u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e can operate in two modes.\n   If a database name is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n   connects to that database and restores archive contents directly into\n   the database.  Otherwise, a script containing the SQL\n   commands necessary to rebuild the database is created and written\n   to a file or standard output.  This script output is equivalent to\n   the plain text output format of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\n   Some of the options controlling the output are therefore analogous to\n   \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e options.\n  \u003c/p\u003e\u003cp\u003e\n   Obviously, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore information\n   that is not present in the archive file.  For instance, if the\n   archive was made using the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edump data as\n   \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e commands\u003c/span\u003e”\u003c/span\u003e option,\n   \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will not be able to load the data\n   using \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e statements.\n  \u003c/p\u003e\u003cdiv class=\"warning\"\u003e\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\u003cp\u003e\n    Restoring a dump causes the destination to execute arbitrary code of the\n    source superusers' choice.  Partial dumps and partial restores do not limit\n    that.  If the source superusers are not trusted, the dumped SQL statements\n    must be inspected before restoring.  Non-plain-text dumps can be inspected\n    by using \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e--file\u003c/code\u003e\n    option.  Note that the client running the dump and restore need not trust\n    the source or destination superusers.\n   \u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-OPTIONS\"\u003e\u003ch2\u003eOptions\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e accepts the following command\n    line arguments.\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Specifies the location of the archive file (or directory, for a\n       directory-format archive) to be restored.\n       If not specified, the standard input is used.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-a\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the data, not the schema (data definitions) or statistics.\n        Table data, large objects, and sequence values are restored,\n        if present in the archive.\n       \u003c/p\u003e\u003cp\u003e\n        This option is similar to, but for historical reasons not identical\n        to, specifying \u003ccode class=\"option\"\u003e--section=data\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--clean\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Before restoring database objects, issue commands\n        to \u003ccode class=\"command\"\u003eDROP\u003c/code\u003e all the objects that will be restored.\n        This option is useful for overwriting an existing database.\n        If any of the objects do not exist in the destination database,\n        ignorable error messages will be reported,\n        unless \u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e is also specified.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Create the database before restoring into it.\n        If \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also specified, drop and\n        recreate the target database before connecting to it.\n       \u003c/p\u003e\u003cp\u003e\n        With \u003ccode class=\"option\"\u003e--create\u003c/code\u003e, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n        also restores the database's comment if any, and any configuration\n        variable settings that are specific to this database, that is,\n        any \u003ccode class=\"command\"\u003eALTER DATABASE ... SET ...\u003c/code\u003e\n        and \u003ccode class=\"command\"\u003eALTER ROLE ... IN DATABASE ... SET ...\u003c/code\u003e\n        commands that mention this database.\n        Access privileges for the database itself are also restored,\n        unless \u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e is specified.\n       \u003c/p\u003e\u003cp\u003e\n        When this option is used, the database named with \u003ccode class=\"option\"\u003e-d\u003c/code\u003e\n        is used only to issue the initial \u003ccode class=\"command\"\u003eDROP DATABASE\u003c/code\u003e and\n        \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e commands.  All data is restored into the\n        database name that appears in the archive.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Connect to database \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e and restore directly\n        into the database.  The \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can\n        be a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e.\n        If so, connection string parameters will override any conflicting\n        command line options.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Exit if an error is encountered while sending SQL commands to\n        the database. The default is to continue and to display a count of\n        errors at the end of the restoration.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify output file for generated script, or for the listing\n        when used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e. Use \u003ccode class=\"literal\"\u003e-\u003c/code\u003e\n        for \u003cspan class=\"systemitem\"\u003estdout\u003c/span\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F \u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--format=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify format of the archive.  It is not necessary to specify\n        the format, since \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will\n        determine the format automatically. If specified, it can be\n        one of the following:\n\n       \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ec\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecustom\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is in the custom format of\n           \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ed\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003edirectory\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is a directory archive.\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etar\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is a \u003ccode class=\"command\"\u003etar\u003c/code\u003e archive.\n          \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-I \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--index=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore definition of named index only.  Multiple indexes\n        may be specified with multiple \u003ccode class=\"option\"\u003e-I\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-j \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--jobs=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Run the most time-consuming steps\n        of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e — those that load data,\n        create indexes, or create constraints — concurrently, using up\n        to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\n        concurrent sessions.  This option can dramatically reduce the time\n        to restore a large database to a server running on a\n        multiprocessor machine.  This option is ignored when emitting a script\n        rather than connecting directly to a database server.\n       \u003c/p\u003e\u003cp\u003e\n        Each job is one process or one thread, depending on the\n        operating system, and uses a separate connection to the\n        server.\n       \u003c/p\u003e\u003cp\u003e\n        The optimal value for this option depends on the hardware\n        setup of the server, of the client, and of the network.\n        Factors include the number of CPU cores and the disk setup.  A\n        good place to start is the number of CPU cores on the server,\n        but values larger than that can also lead to faster restore\n        times in many cases.  Of course, values that are too high will\n        lead to decreased performance because of thrashing.\n       \u003c/p\u003e\u003cp\u003e\n        Only the custom and directory archive formats are supported\n        with this option.\n        The input must be a regular file or directory (not, for example, a\n        pipe or standard input).  Also, multiple\n        jobs cannot be used together with the\n        option \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--list\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        List the table of contents of the archive. The output of this operation\n        can be used as input to the \u003ccode class=\"option\"\u003e-L\u003c/code\u003e option.  Note that\n        if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are\n        used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e, they will restrict the items listed.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-list=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only those archive elements that are listed in \u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e, and restore them in the\n        order they appear in the file.  Note that\n        if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are\n        used with \u003ccode class=\"option\"\u003e-L\u003c/code\u003e, they will further restrict the items restored.\n       \u003c/p\u003e\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e is normally created by\n        editing the output of a previous \u003ccode class=\"option\"\u003e-l\u003c/code\u003e operation.\n        Lines can be moved or removed, and can also\n        be commented out by placing a semicolon (\u003ccode class=\"literal\"\u003e;\u003c/code\u003e) at the\n        start of the line.  See below for examples.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--schema=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only objects that are in the named schema.  Multiple schemas\n        may be specified with multiple \u003ccode class=\"option\"\u003e-n\u003c/code\u003e switches.  This can be\n        combined with the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e option to restore just a\n        specific table.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exclude-schema=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not restore objects that are in the named schema.  Multiple schemas\n        to be excluded may be specified with multiple \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switches.\n       \u003c/p\u003e\u003cp\u003e\n        When both \u003ccode class=\"option\"\u003e-n\u003c/code\u003e and \u003ccode class=\"option\"\u003e-N\u003c/code\u003e are given for the same\n        schema name, the \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switch wins and the schema is excluded.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-O\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-owner\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to set\n        ownership of objects to match the original database.\n        By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e issues\n        \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e or\n        \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e\n        statements to set ownership of created schema elements.\n        These statements will fail unless the initial connection to the\n        database is made by a superuser\n        (or the same user that owns all of the objects in the script).\n        With \u003ccode class=\"option\"\u003e-O\u003c/code\u003e, any user name can be used for the\n        initial connection, and this user will own all the created objects.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P \u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--function=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore the named function only.  Be careful to spell the function\n        name and arguments exactly as they appear in the dump file's table\n        of contents.  Multiple functions may be specified with multiple\n        \u003ccode class=\"option\"\u003e-P\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-reconnect\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is obsolete but still accepted for backwards\n        compatibility.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--schema-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the schema (data definitions), not data,\n        to the extent that schema entries are present in the archive.\n       \u003c/p\u003e\u003cp\u003e\n        This option cannot be used with \u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e\n        or \u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e.\n        It is similar to, but for historical reasons not identical to,\n        specifying\n        \u003ccode class=\"option\"\u003e--section=pre-data --section=post-data --no-statistics\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n        (Do not confuse this with the \u003ccode class=\"option\"\u003e--schema\u003c/code\u003e option, which\n        uses the word \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eschema\u003c/span\u003e”\u003c/span\u003e in a different meaning.)\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--superuser=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify the superuser user name to use when disabling triggers.\n        This is relevant only if \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--table=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore definition and/or data of only the named table.\n        For this purpose, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etable\u003c/span\u003e”\u003c/span\u003e includes views, materialized views,\n        sequences, and foreign tables.  Multiple tables\n        can be selected by writing multiple \u003ccode class=\"option\"\u003e-t\u003c/code\u003e switches.\n        This option can be combined with the \u003ccode class=\"option\"\u003e-n\u003c/code\u003e option to\n        specify table(s) in a particular schema.\n       \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         When \u003ccode class=\"option\"\u003e-t\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n         makes no attempt to restore any other database objects that the\n         selected table(s) might depend upon.  Therefore, there is no\n         guarantee that a specific-table restore into a clean database will\n         succeed.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         This flag does not behave identically to the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e\n         flag of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.  There is not currently\n         any provision for wild-card matching in \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e,\n         nor can you include a schema name within its \u003ccode class=\"option\"\u003e-t\u003c/code\u003e.\n         And, while \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e\n         flag will also dump subsidiary objects (such as indexes) of the\n         selected table(s),\n         \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e\n         flag does not include such subsidiary objects.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         In versions prior to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, this flag\n         matched only tables, not any other type of relation.\n        \u003c/p\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--trigger=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore named trigger only.  Multiple triggers may be specified with\n        multiple \u003ccode class=\"option\"\u003e-T\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies verbose mode.  This will cause\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to output detailed object\n        comments and start/stop times to the output file, and progress\n        messages to standard error.\n        Repeating the option causes additional debug-level messages\n        to appear on standard error.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Print the \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e version and exit.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-privileges\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Prevent restoration of access privileges (grant/revoke commands).\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Execute the restore as a single transaction (that is, wrap the\n        emitted commands in \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e).  This\n        ensures that either all the commands complete successfully, or no\n        changes are applied. This option implies\n        \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is relevant only when performing a restore without schema.\n        It instructs \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to execute commands\n        to temporarily disable triggers on the target tables while\n        the data is restored.  Use this if you have referential\n        integrity checks or other triggers on the tables that you\n        do not want to invoke during data restore.\n       \u003c/p\u003e\u003cp\u003e\n        Presently, the commands emitted for\n        \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e must be done as superuser.  So you\n        should also specify a superuser name with \u003ccode class=\"option\"\u003e-S\u003c/code\u003e or,\n        preferably, run \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e as a\n        \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e superuser.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--enable-row-security\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is relevant only when restoring the contents of a table\n        which has row security.  By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will set\n        \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e to off, to ensure\n        that all data is restored in to the table.  If the user does not have\n        sufficient privileges to bypass row security, then an error is thrown.\n        This parameter instructs \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to set\n        \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e to on instead, allowing the user to attempt to restore\n        the contents of the table with row security enabled.  This might still\n        fail if the user does not have the right to insert the rows from the\n        dump into the table.\n       \u003c/p\u003e\u003cp\u003e\n        Note that this option currently also requires the dump be in \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e\n        format, as \u003ccode class=\"command\"\u003eCOPY FROM\u003c/code\u003e does not support row security.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--filter=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify a filename from which to read patterns for objects excluded\n        or included from restore. The patterns are interpreted according to the\n        same rules as\n        \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e for including objects in schemas,\n        \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e for excluding objects in schemas,\n        \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e for restoring named functions,\n        \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e for restoring named indexes,\n        \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e for restoring named tables\n        or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e for restoring triggers.\n        To read from \u003ccode class=\"literal\"\u003eSTDIN\u003c/code\u003e, use \u003ccode class=\"filename\"\u003e-\u003c/code\u003e as the\n        filename.  The \u003ccode class=\"option\"\u003e--filter\u003c/code\u003e option can be specified in\n        conjunction with the above listed options for including or excluding\n        objects, and can also be specified more than once for multiple filter\n        files.\n       \u003c/p\u003e\u003cp\u003e\n        The file lists one database pattern per row, with the following format:\n\u003c/p\u003e\u003cpre class=\"synopsis\"\u003e{ include | exclude } { function | index | schema | table | trigger } \u003cem class=\"replaceable\"\u003e\u003ccode\u003ePATTERN\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        The first keyword specifies whether the objects matched by the pattern\n        are to be included or excluded. The second keyword specifies the type\n        of object to be filtered using the pattern:\n        \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003efunction\u003c/code\u003e: functions, works like the\n           \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003eindex\u003c/code\u003e: indexes, works like the\n           \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003eschema\u003c/code\u003e: schemas, works like the\n           \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e and\n           \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e options.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003etable\u003c/code\u003e: tables, works like the\n           \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003etrigger\u003c/code\u003e: triggers, works like the\n           \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        Lines starting with \u003ccode class=\"literal\"\u003e#\u003c/code\u003e are considered comments and\n        ignored. Comments can be placed after an object pattern row as well.\n        Blank lines are also ignored. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003ePatterns\u003c/a\u003e\n        for how to perform quoting in patterns.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Use \u003ccode class=\"literal\"\u003eDROP ... IF EXISTS\u003c/code\u003e commands to drop objects\n        in \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e mode.  This suppresses \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edoes not\n        exist\u003c/span\u003e”\u003c/span\u003e errors that might otherwise be reported.  This\n        option is not valid unless \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also\n        specified.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-comments\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore comments, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore data, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-for-failed-tables\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        By default, table data is restored even if the creation command\n        for the table failed (e.g., because it already exists).\n        With this option, data for such a table is skipped.\n        This behavior is useful if the target database already\n        contains the desired table contents.  For example,\n        auxiliary tables for \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extensions\n        such as \u003cspan class=\"productname\"\u003ePostGIS\u003c/span\u003e might already be loaded in\n        the target database; specifying this option prevents duplicate\n        or obsolete data from being loaded into them.\n       \u003c/p\u003e\u003cp\u003e\n        This option is effective only when restoring directly into a\n        database, not when producing SQL script output.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-policies\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore row security policies, even if\n        the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-publications\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore publications, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-schema\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore schema (data definitions), even if\n        the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-security-labels\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore security labels,\n        even if the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore statistics, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-subscriptions\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore subscriptions, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-table-access-method\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to select table access methods.\n        With this option, all objects will be created with whichever\n        table access method is the default during restore.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-tablespaces\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to select tablespaces.\n        With this option, all objects will be created in whichever\n        tablespace is the default during restore.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--restrict-key=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Use the provided string as the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e\n\u003ccode class=\"command\"\u003e\\restrict\u003c/code\u003e key in the dump output.  This can only be\n        specified for SQL script output, i.e., when the \u003ccode class=\"option\"\u003e--file\u003c/code\u003e\n        option is used.  If no restrict key is specified,\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will generate a random one as\n        needed.  Keys may contain only alphanumeric characters.\n       \u003c/p\u003e\u003cp\u003e\n        This option is primarily intended for testing purposes and other\n        scenarios that require repeatable output (e.g., comparing dump files).\n        It is not recommended for general use, as a malicious server with\n        advance knowledge of the key may be able to inject arbitrary code that\n        will be executed on the machine that runs\n        \u003cspan class=\"application\"\u003epsql\u003c/span\u003e with the dump output.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--section=\u003cem class=\"replaceable\"\u003e\u003ccode\u003esectionname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n          Only restore the named section. The section name can be\n          \u003ccode class=\"option\"\u003epre-data\u003c/code\u003e, \u003ccode class=\"option\"\u003edata\u003c/code\u003e, or \u003ccode class=\"option\"\u003epost-data\u003c/code\u003e.\n          This option can be specified more than once to select multiple\n          sections. The default is to restore all sections.\n         \u003c/p\u003e\u003cp\u003e\n          The data section contains actual table data as well as large-object\n          definitions.\n          Post-data items consist of definitions of indexes, triggers, rules\n          and constraints other than validated check constraints.\n          Pre-data items consist of all other data definition items.\n         \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Output commands to restore statistics, if the archive contains them.\n        This is the default.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the statistics, not schema (data definitions) or data.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--strict-names\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Require that each schema\n        (\u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e) and table\n        (\u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e) qualifier match at\n        least one schema/table in the file to be restored.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--transaction-size=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Execute the restore as a series of transactions, each processing\n        up to \u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e database\n        objects.  This option implies \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e offers an intermediate choice\n        between the default behavior (one transaction per SQL command)\n        and \u003ccode class=\"option\"\u003e-1\u003c/code\u003e/\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e\n        (one transaction for all restored objects).\n        While \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e has the least\n        overhead, it may be impractical for large databases because the\n        transaction will take a lock on each restored object, possibly\n        exhausting the server's lock table space.\n        Using \u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e with a size of a few\n        thousand objects offers nearly the same performance benefits while\n        capping the amount of lock table space needed.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-set-session-authorization\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Output SQL-standard \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e commands\n        instead of \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e commands to determine object\n        ownership.  This makes the dump more standards-compatible, but\n        depending on the history of the objects in the dump, might not restore\n        properly.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Show help about \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e command line\n       arguments, and exit.\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e also accepts\n    the following command line arguments for connection parameters:\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies the host name of the machine on which the server is\n        running.  If the value begins with a slash, it is used as the\n        directory for the Unix domain socket. The default is taken\n        from the \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set,\n        else a Unix domain socket connection is attempted.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies the TCP port or local Unix domain socket file\n        extension on which the server is listening for connections.\n        Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if\n        set, or a compiled-in default.\n        \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        User name to connect as.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Never issue a password prompt.  If the server requires\n        password authentication and a password is not available by\n        other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the\n        connection attempt will fail.  This option can be useful in\n        batch jobs and scripts where no user is present to enter a\n        password.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Force \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to prompt for a\n        password before connecting to a database.\n       \u003c/p\u003e\u003cp\u003e\n        This option is never essential, since\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will automatically prompt\n        for a password if the server demands password authentication.\n        However, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will waste a\n        connection attempt finding out that the server wants a password.\n        In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra\n        connection attempt.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--role=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies a role name to be used to perform the restore.\n        This option causes \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to issue a\n        \u003ccode class=\"command\"\u003eSET ROLE\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e\n        command after connecting to the database. It is useful when the\n        authenticated user (specified by \u003ccode class=\"option\"\u003e-U\u003c/code\u003e) lacks privileges\n        needed by \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, but can switch to a role with\n        the required rights.  Some installations have a policy against\n        logging in directly as a superuser, and use of this option allows\n        restores to be performed without violating the policy.\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.7\"\u003e\u003ch2\u003eEnvironment\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGOPTIONS\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      Default connection parameters\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      Specifies whether to use color in diagnostic messages. Possible values\n      are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and\n      \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n   This utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities,\n   also uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e\n   (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).  However, it does not read\n   \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e when a database name is not supplied.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DIAGNOSTICS\"\u003e\u003ch2\u003eDiagnostics\u003c/h2\u003e\u003cp\u003e\n   When a direct database connection is specified using the\n   \u003ccode class=\"option\"\u003e-d\u003c/code\u003e option, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n   internally executes SQL statements. If you have\n   problems running \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, make sure\n   you are able to select information from the database using, for\n   example, \u003ca class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e.  Also, any default connection\n   settings and environment variables used by the\n   \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e front-end library will apply.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-NOTES\"\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003e\n   If your installation has any local additions to the\n   \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e database, be careful to load the output of\n   \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e into a truly empty database;\n   otherwise you are likely to get errors due to duplicate definitions\n   of the added objects.  To make an empty database without any local\n   additions, copy from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, for example:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE DATABASE foo WITH TEMPLATE template0;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   The limitations of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e are detailed below.\n\n   \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n      When restoring data to a pre-existing table and the option\n      \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used,\n      \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e emits commands\n      to disable triggers on user tables before inserting the data, then emits commands to\n      re-enable them after the data has been inserted.  If the restore is stopped in the\n      middle, the system catalogs might be left in the wrong state.\n     \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore large objects\n      selectively;  for instance, only those for a specific table.  If\n      an archive contains large objects, then all large objects will be\n      restored, or none of them if they are excluded via \u003ccode class=\"option\"\u003e-L\u003c/code\u003e,\n      \u003ccode class=\"option\"\u003e-t\u003c/code\u003e, or other options.\n     \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   See also the \u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e documentation for details on\n   limitations of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\n  \u003c/p\u003e\u003cp\u003e\n   By default, \u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e will restore optimizer statistics\n   if included in the dump file.  If not all statistics were restored, it may\n   be useful to run \u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e on each restored table so the\n   optimizer has useful statistics; see \u003ca class=\"xref\" href=\"/docs/18/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3. Updating Planner Statistics\"\u003eSection 24.1.3\u003c/a\u003e and \u003ca class=\"xref\" href=\"/docs/18/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6. The Autovacuum Daemon\"\u003eSection 24.1.6\u003c/a\u003e for more\n   information.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-EXAMPLES\"\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003e\n   Assume we have dumped a database called \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e into a\n   custom-format dump file:\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_dump -Fc mydb \u0026gt; db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   To drop the database and recreate it from the dump:\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003edropdb mydb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -C -d postgres db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   The database named in the \u003ccode class=\"option\"\u003e-d\u003c/code\u003e switch can be any database existing\n   in the cluster; \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e only uses it to issue the\n   \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e command for \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e.  With\n   \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, data is always restored into the database name that appears\n   in the dump file.\n  \u003c/p\u003e\u003cp\u003e\n   To restore the dump into a new database called \u003ccode class=\"literal\"\u003enewdb\u003c/code\u003e:\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003ecreatedb -T template0 newdb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -d newdb db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   Notice we don't use \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, and instead connect directly to the\n   database to be restored into.  Also note that we clone the new database\n   from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, to ensure it is\n   initially empty.\n  \u003c/p\u003e\u003cp\u003e\n   To reorder database items, it is first necessary to dump the table of\n   contents of the archive:\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -l db.dump \u0026gt; db.list\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n   The listing file consists of a header and one line for each item, e.g.:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e;\n; Archive created at Mon Sep 14 13:55:39 2009\n;     dbname: DBDEMOS\n;     TOC Entries: 81\n;     Compression: 9\n;     Dump Version: 1.10-0\n;     Format: CUSTOM\n;     Integer: 4 bytes\n;     Offset: 8 bytes\n;     Dumped from database version: 8.3.5\n;     Dumped by pg_dump version: 8.3.8\n;\n;\n; Selected TOC Entries:\n;\n3; 2615 2200 SCHEMA - public pasha\n1861; 0 0 COMMENT - SCHEMA public pasha\n1862; 0 0 ACL - public pasha\n317; 1247 17715 TYPE public composite pasha\n319; 1247 25899 DOMAIN public domain0 pasha\n\u003c/pre\u003e\u003cp\u003e\n   Semicolons start a comment, and the numbers at the start of lines refer to the\n   internal archive ID assigned to each item.\n  \u003c/p\u003e\u003cp\u003e\n   Lines in the file can be commented out, deleted, and reordered. For example:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e10; 145433 TABLE map_resolutions postgres\n;2; 145344 TABLE species postgres\n;4; 145359 TABLE nt_header postgres\n6; 145402 TABLE species_records postgres\n;8; 145416 TABLE ss_old postgres\n\u003c/pre\u003e\u003cp\u003e\n   could be used as input to \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e and would only restore\n   items 10 and 6, in that order:\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -L db.list db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.11\"\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dumpall\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","manual_path":"app-pgrestore.html","options":[{"description":"Restore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive. This option is similar to, but for historical reasons not identical to, specifying --section=data .","names":["-a","--data-only"],"signature":"-a --data-only","source_url":"/docs/18/app-pgrestore.html","summary":"Restore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive."},{"description":"Before restoring database objects, issue commands to DROP all the objects that will be restored. This option is useful for overwriting an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported, unless --if-exists is also specified.","names":["-c","--clean"],"signature":"-c --clean","source_url":"/docs/18/app-pgrestore.html","summary":"Before restoring database objects, issue commands to DROP all the objects that will be restored. This option is useful for overwriting an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported, unless --if-exists is also specified."},{"description":"Create the database before restoring into it. If --clean is also specified, drop and recreate the target database before connecting to it. With --create , pg_restore also restores the database's comment if any, and any configuration variable settings that are specific to this database, that is, any ALTER DATABASE ... SET ... and ALTER ROLE ... IN DATABASE ... SET ... commands that mention this database. Access privileges for the database itself are also restored, unless --no-acl is specified. When this option is used, the database named with -d is used only to issue the initial DROP DATABASE and CREATE DATABASE commands. All data is restored into the database name that appears in the archive.","names":["-C","--create"],"signature":"-C --create","source_url":"/docs/18/app-pgrestore.html","summary":"Create the database before restoring into it. If --clean is also specified, drop and recreate the target database before connecting to it."},{"description":"Connect to database dbname and restore directly into the database. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.","names":["-d dbname","--dbname= dbname"],"signature":"-d dbname --dbname= dbname","source_url":"/docs/18/app-pgrestore.html","summary":"Connect to database dbname and restore directly into the database. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."},{"description":"Exit if an error is encountered while sending SQL commands to the database. The default is to continue and to display a count of errors at the end of the restoration.","names":["-e","--exit-on-error"],"signature":"-e --exit-on-error","source_url":"/docs/18/app-pgrestore.html","summary":"Exit if an error is encountered while sending SQL commands to the database. The default is to continue and to display a count of errors at the end of the restoration."},{"description":"Specify output file for generated script, or for the listing when used with -l . Use - for stdout .","names":["-f filename","--file= filename"],"signature":"-f filename --file= filename","source_url":"/docs/18/app-pgrestore.html","summary":"Specify output file for generated script, or for the listing when used with -l . Use - for stdout ."},{"description":"Specify format of the archive. It is not necessary to specify the format, since pg_restore will determine the format automatically. If specified, it can be one of the following: c custom The archive is in the custom format of pg_dump . d directory The archive is a directory archive. t tar The archive is a tar archive.","names":["-F format","--format= format"],"signature":"-F format --format= format","source_url":"/docs/18/app-pgrestore.html","summary":"Specify format of the archive. It is not necessary to specify the format, since pg_restore will determine the format automatically. If specified, it can be one of the following:"},{"description":"Restore definition of named index only. Multiple indexes may be specified with multiple -I switches.","names":["-I index","--index= index"],"signature":"-I index --index= index","source_url":"/docs/18/app-pgrestore.html","summary":"Restore definition of named index only. Multiple indexes may be specified with multiple -I switches."},{"description":"Run the most time-consuming steps of pg_restore — those that load data, create indexes, or create constraints — concurrently, using up to number-of-jobs concurrent sessions. This option can dramatically reduce the time to restore a large database to a server running on a multiprocessor machine. This option is ignored when emitting a script rather than connecting directly to a database server. Each job is one process or one thread, depending on the operating system, and uses a separate connection to the server. The optimal value for this option depends on the hardware setup of the server, of the client, and of the network. Factors include the number of CPU cores and the disk setup. A 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 decreased performance because of thrashing. Only the custom and directory archive formats are supported with this option. The input must be a regular file or directory (not, for example, a pipe or standard input). Also, multiple jobs cannot be used together with the option --single-transaction .","names":["-j number-of-jobs","--jobs= number-of-jobs"],"signature":"-j number-of-jobs --jobs= number-of-jobs","source_url":"/docs/18/app-pgrestore.html","summary":"Run the most time-consuming steps of pg_restore — those that load data, create indexes, or create constraints — concurrently, using up to number-of-jobs concurrent sessions. This option can dramatically reduce the time to restore a large database to a server running on a multiprocessor machine. This option is ignored when emitting a script rather than connecting directly to a database server."},{"description":"List the table of contents of the archive. The output of this operation can be used as input to the -L option. Note that if filtering switches such as -n or -t are used with -l , they will restrict the items listed.","names":["-l","--list"],"signature":"-l --list","source_url":"/docs/18/app-pgrestore.html","summary":"List the table of contents of the archive. The output of this operation can be used as input to the -L option. Note that if filtering switches such as -n or -t are used with -l , they will restrict the items listed."},{"description":"Restore only those archive elements that are listed in list-file , and restore them in the order they appear in the file. Note that if filtering switches such as -n or -t are used with -L , they will further restrict the items restored. list-file is normally created by editing the output of a previous -l operation. Lines can be moved or removed, and can also be commented out by placing a semicolon ( ; ) at the start of the line. See below for examples.","names":["-L list-file","--use-list= list-file"],"signature":"-L list-file --use-list= list-file","source_url":"/docs/18/app-pgrestore.html","summary":"Restore only those archive elements that are listed in list-file , and restore them in the order they appear in the file. Note that if filtering switches such as -n or -t are used with -L , they will further restrict the items restored."},{"description":"Restore only objects that are in the named schema. Multiple schemas may be specified with multiple -n switches. This can be combined with the -t option to restore just a specific table.","names":["-n schema","--schema= schema"],"signature":"-n schema --schema= schema","source_url":"/docs/18/app-pgrestore.html","summary":"Restore only objects that are in the named schema. Multiple schemas may be specified with multiple -n switches. This can be combined with the -t option to restore just a specific table."},{"description":"Do not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple -N switches. When both -n and -N are given for the same schema name, the -N switch wins and the schema is excluded.","names":["-N schema","--exclude-schema= schema"],"signature":"-N schema --exclude-schema= schema","source_url":"/docs/18/app-pgrestore.html","summary":"Do not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple -N switches."},{"description":"Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O , any user name can be used for the initial connection, and this user will own all the created objects.","names":["-O","--no-owner"],"signature":"-O --no-owner","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O , any user name can be used for the initial connection, and this user will own all the created objects."},{"description":"Restore the named function only. Be careful to spell the function name and arguments exactly as they appear in the dump file's table of contents. Multiple functions may be specified with multiple -P switches.","names":["-P function-name(argtype [, ...])","--function= function-name(argtype [, ...])"],"signature":"-P function-name(argtype [, ...]) --function= function-name(argtype [, ...])","source_url":"/docs/18/app-pgrestore.html","summary":"Restore the named function only. Be careful to spell the function name and arguments exactly as they appear in the dump file's table of contents. Multiple functions may be specified with multiple -P switches."},{"description":"This option is obsolete but still accepted for backwards compatibility.","names":["-R","--no-reconnect"],"signature":"-R --no-reconnect","source_url":"/docs/18/app-pgrestore.html","summary":"This option is obsolete but still accepted for backwards compatibility."},{"description":"Restore only the schema (data definitions), not data, to the extent that schema entries are present in the archive. This option cannot be used with --data-only or --statistics-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data --no-statistics . (Do not confuse this with the --schema option, which uses the word “ schema ” in a different meaning.)","names":["-s","--schema-only"],"signature":"-s --schema-only","source_url":"/docs/18/app-pgrestore.html","summary":"Restore only the schema (data definitions), not data, to the extent that schema entries are present in the archive."},{"description":"Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used.","names":["-S username","--superuser= username"],"signature":"-S username --superuser= username","source_url":"/docs/18/app-pgrestore.html","summary":"Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used."},{"description":"Restore definition and/or data of only the named table. For this purpose, “ table ” includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. This option can be combined with the -n option to specify table(s) in a particular schema. Note When -t is specified, pg_restore makes no attempt to restore any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that a specific-table restore into a clean database will succeed. Note This flag does not behave identically to the -t flag of pg_dump . There is not currently any provision for wild-card matching in pg_restore , nor can you include a schema name within its -t . And, while pg_dump 's -t flag will also dump subsidiary objects (such as indexes) of the selected table(s), pg_restore 's -t flag does not include such subsidiary objects. Note In versions prior to PostgreSQL 9.6, this flag matched only tables, not any other type of relation.","names":["-t table","--table= table"],"signature":"-t table --table= table","source_url":"/docs/18/app-pgrestore.html","summary":"Restore definition and/or data of only the named table. For this purpose, “ table ” includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. This option can be combined with the -n option to specify table(s) in a particular schema."},{"description":"Restore named trigger only. Multiple triggers may be specified with multiple -T switches.","names":["-T trigger","--trigger= trigger"],"signature":"-T trigger --trigger= trigger","source_url":"/docs/18/app-pgrestore.html","summary":"Restore named trigger only. Multiple triggers may be specified with multiple -T switches."},{"description":"Specifies verbose mode. This will cause pg_restore to output detailed object comments and start/stop times to the output file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.","names":["-v","--verbose"],"signature":"-v --verbose","source_url":"/docs/18/app-pgrestore.html","summary":"Specifies verbose mode. This will cause pg_restore to output detailed object comments and start/stop times to the output file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."},{"description":"Print the pg_restore version and exit.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/app-pgrestore.html","summary":"Print the pg_restore version and exit."},{"description":"Prevent restoration of access privileges (grant/revoke commands).","names":["-x","--no-privileges","--no-acl"],"signature":"-x --no-privileges --no-acl","source_url":"/docs/18/app-pgrestore.html","summary":"Prevent restoration of access privileges (grant/revoke commands)."},{"description":"Execute the restore as a single transaction (that is, wrap the emitted commands in BEGIN / COMMIT ). This ensures that either all the commands complete successfully, or no changes are applied. This option implies --exit-on-error .","names":["-1","--single-transaction"],"signature":"-1 --single-transaction","source_url":"/docs/18/app-pgrestore.html","summary":"Execute the restore as a single transaction (that is, wrap the emitted commands in BEGIN / COMMIT ). This ensures that either all the commands complete successfully, or no changes are applied. This option implies --exit-on-error ."},{"description":"This option is relevant only when performing a restore without schema. It instructs pg_restore to execute commands to temporarily disable triggers on the target tables while the data is restored. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data restore. Presently, the commands emitted for --disable-triggers must be done as superuser. So you should also specify a superuser name with -S or, preferably, run pg_restore as a PostgreSQL superuser.","names":["--disable-triggers"],"signature":"--disable-triggers","source_url":"/docs/18/app-pgrestore.html","summary":"This option is relevant only when performing a restore without schema. It instructs pg_restore to execute commands to temporarily disable triggers on the target tables while the data is restored. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data restore."},{"description":"This option is relevant only when restoring the contents of a table which has row security. By default, pg_restore will set row_security to off, to ensure that all data is restored in to the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_restore to set row_security to on instead, allowing the user to attempt to restore the contents of the table with row security enabled. This might still fail if the user does not have the right to insert the rows from the dump into the table. Note that this option currently also requires the dump be in INSERT format, as COPY FROM does not support row security.","names":["--enable-row-security"],"signature":"--enable-row-security","source_url":"/docs/18/app-pgrestore.html","summary":"This option is relevant only when restoring the contents of a table which has row security. By default, pg_restore will set row_security to off, to ensure that all data is restored in to the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_restore to set row_security to on instead, allowing the user to attempt to restore the contents of the table with row security enabled. This might still fail if the user does not have the right to insert the rows from the dump into the table."},{"description":"Specify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as -n / --schema for including objects in schemas, -N / --exclude-schema for excluding objects in schemas, -P / --function for restoring named functions, -I / --index for restoring named indexes, -t / --table for restoring named tables or -T / --trigger for restoring triggers. To read from STDIN , use - as the filename. The --filter option can be specified in conjunction with the above listed options for including or excluding objects, and can also be specified more than once for multiple filter files. The file lists one database pattern per row, with the following format: { include | exclude } { function | index | schema | table | trigger } PATTERN The first keyword specifies whether the objects matched by the pattern are to be included or excluded. The second keyword specifies the type of object to be filtered using the pattern: function : functions, works like the -P / --function option. This keyword can only be used with the include keyword. index : indexes, works like the -I / --index option. This keyword can only be used with the include keyword. schema : schemas, works like the -n / --schema and -N / --exclude-schema options. table : tables, works like the -t / --table option. This keyword can only be used with the include keyword. trigger : triggers, works like the -T / --trigger option. This keyword can only be used with the include keyword. Lines starting with # are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See Patterns for how to perform quoting in patterns.","names":["--filter= filename"],"signature":"--filter= filename","source_url":"/docs/18/app-pgrestore.html","summary":"Specify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as -n / --schema for including objects in schemas, -N / --exclude-schema for excluding objects in schemas, -P / --function for restoring named functions, -I / --index for restoring named indexes, -t / --table for restoring named tables or -T / --trigger for restoring triggers. To read from STDIN , use - as the filename. The --filter option can be specified in conjunction with the above listed options for including or excluding objects, and can also be specified more than once for multiple filter files."},{"description":"Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses “ does not exist ” errors that might otherwise be reported. This option is not valid unless --clean is also specified.","names":["--if-exists"],"signature":"--if-exists","source_url":"/docs/18/app-pgrestore.html","summary":"Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses “ does not exist ” errors that might otherwise be reported. This option is not valid unless --clean is also specified."},{"description":"Do not output commands to restore comments, even if the archive contains them.","names":["--no-comments"],"signature":"--no-comments","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore comments, even if the archive contains them."},{"description":"Do not output commands to restore data, even if the archive contains them.","names":["--no-data"],"signature":"--no-data","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore data, even if the archive contains them."},{"description":"By default, table data is restored even if the creation command for the table failed (e.g., because it already exists). With this option, data for such a table is skipped. This behavior is useful if the target database already contains the desired table contents. For example, auxiliary tables for PostgreSQL extensions such as PostGIS might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them. This option is effective only when restoring directly into a database, not when producing SQL script output.","names":["--no-data-for-failed-tables"],"signature":"--no-data-for-failed-tables","source_url":"/docs/18/app-pgrestore.html","summary":"By default, table data is restored even if the creation command for the table failed (e.g., because it already exists). With this option, data for such a table is skipped. This behavior is useful if the target database already contains the desired table contents. For example, auxiliary tables for PostgreSQL extensions such as PostGIS might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them."},{"description":"Do not output commands to restore row security policies, even if the archive contains them.","names":["--no-policies"],"signature":"--no-policies","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore row security policies, even if the archive contains them."},{"description":"Do not output commands to restore publications, even if the archive contains them.","names":["--no-publications"],"signature":"--no-publications","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore publications, even if the archive contains them."},{"description":"Do not output commands to restore schema (data definitions), even if the archive contains them.","names":["--no-schema"],"signature":"--no-schema","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore schema (data definitions), even if the archive contains them."},{"description":"Do not output commands to restore security labels, even if the archive contains them.","names":["--no-security-labels"],"signature":"--no-security-labels","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore security labels, even if the archive contains them."},{"description":"Do not output commands to restore statistics, even if the archive contains them.","names":["--no-statistics"],"signature":"--no-statistics","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore statistics, even if the archive contains them."},{"description":"Do not output commands to restore subscriptions, even if the archive contains them.","names":["--no-subscriptions"],"signature":"--no-subscriptions","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to restore subscriptions, even if the archive contains them."},{"description":"Do not output commands to select table access methods. With this option, all objects will be created with whichever table access method is the default during restore.","names":["--no-table-access-method"],"signature":"--no-table-access-method","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to select table access methods. With this option, all objects will be created with whichever table access method is the default during restore."},{"description":"Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.","names":["--no-tablespaces"],"signature":"--no-tablespaces","source_url":"/docs/18/app-pgrestore.html","summary":"Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore."},{"description":"Use the provided string as the psql \\restrict key in the dump output. This can only be specified for SQL script output, i.e., when the --file option is used. If no restrict key is specified, pg_restore will generate a random one as needed. Keys may contain only alphanumeric characters. This option is primarily intended for testing purposes and other scenarios that require repeatable output (e.g., comparing dump files). It is not recommended for general use, as a malicious server with advance knowledge of the key may be able to inject arbitrary code that will be executed on the machine that runs psql with the dump output.","names":["--restrict-key= restrict_key"],"signature":"--restrict-key= restrict_key","source_url":"/docs/18/app-pgrestore.html","summary":"Use the provided string as the psql \\restrict key in the dump output. This can only be specified for SQL script output, i.e., when the --file option is used. If no restrict key is specified, pg_restore will generate a random one as needed. Keys may contain only alphanumeric characters."},{"description":"Only restore the named section. The section name can be pre-data , data , or post-data . This option can be specified more than once to select multiple sections. The default is to restore all sections. The data section contains actual table data as well as large-object definitions. Post-data items consist of definitions of indexes, triggers, rules and constraints other than validated check constraints. Pre-data items consist of all other data definition items.","names":["--section= sectionname"],"signature":"--section= sectionname","source_url":"/docs/18/app-pgrestore.html","summary":"Only restore the named section. The section name can be pre-data , data , or post-data . This option can be specified more than once to select multiple sections. The default is to restore all sections."},{"description":"Output commands to restore statistics, if the archive contains them. This is the default.","names":["--statistics"],"signature":"--statistics","source_url":"/docs/18/app-pgrestore.html","summary":"Output commands to restore statistics, if the archive contains them. This is the default."},{"description":"Restore only the statistics, not schema (data definitions) or data.","names":["--statistics-only"],"signature":"--statistics-only","source_url":"/docs/18/app-pgrestore.html","summary":"Restore only the statistics, not schema (data definitions) or data."},{"description":"Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the file to be restored.","names":["--strict-names"],"signature":"--strict-names","source_url":"/docs/18/app-pgrestore.html","summary":"Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the file to be restored."},{"description":"Execute the restore as a series of transactions, each processing up to N database objects. This option implies --exit-on-error . --transaction-size offers an intermediate choice between the default behavior (one transaction per SQL command) and -1 / --single-transaction (one transaction for all restored objects). While --single-transaction has the least overhead, it may be impractical for large databases because the transaction will take a lock on each restored object, possibly exhausting the server's lock table space. Using --transaction-size with a size of a few thousand objects offers nearly the same performance benefits while capping the amount of lock table space needed.","names":["--transaction-size= N"],"signature":"--transaction-size= N","source_url":"/docs/18/app-pgrestore.html","summary":"Execute the restore as a series of transactions, each processing up to N database objects. This option implies --exit-on-error ."},{"description":"Output SQL-standard SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to determine object ownership. This makes the dump more standards-compatible, but depending on the history of the objects in the dump, might not restore properly.","names":["--use-set-session-authorization"],"signature":"--use-set-session-authorization","source_url":"/docs/18/app-pgrestore.html","summary":"Output SQL-standard SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to determine object ownership. This makes the dump more standards-compatible, but depending on the history of the objects in the dump, might not restore properly."},{"description":"Show help about pg_restore command line arguments, and exit.","names":["-?","--help"],"signature":"-? --help","source_url":"/docs/18/app-pgrestore.html","summary":"Show help about pg_restore command line arguments, and exit."},{"description":"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 PGHOST environment variable, if set, else a Unix domain socket connection is attempted.","names":["-h host","--host= host"],"signature":"-h host --host= host","source_url":"/docs/18/app-pgrestore.html","summary":"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 PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"description":"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.","names":["-p port","--port= port"],"signature":"-p port --port= port","source_url":"/docs/18/app-pgrestore.html","summary":"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."},{"description":"User name to connect as.","names":["-U username","--username= username"],"signature":"-U username --username= username","source_url":"/docs/18/app-pgrestore.html","summary":"User name to connect as."},{"description":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.","names":["-w","--no-password"],"signature":"-w --no-password","source_url":"/docs/18/app-pgrestore.html","summary":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"description":"Force pg_restore to prompt for a password before connecting to a database. This option is never essential, since pg_restore will automatically prompt for a password if the server demands password authentication. However, pg_restore will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.","names":["-W","--password"],"signature":"-W --password","source_url":"/docs/18/app-pgrestore.html","summary":"Force pg_restore to prompt for a password before connecting to a database."},{"description":"Specifies a role name to be used to perform the restore. This option causes pg_restore to issue a SET ROLE rolename command after connecting to the database. It is useful when the authenticated user (specified by -U ) lacks privileges needed by pg_restore , but can switch to a role with the required rights. Some installations have a policy against logging in directly as a superuser, and use of this option allows restores to be performed without violating the policy.","names":["--role= rolename"],"signature":"--role= rolename","source_url":"/docs/18/app-pgrestore.html","summary":"Specifies a role name to be used to perform the restore. This option causes pg_restore to issue a SET ROLE rolename command after connecting to the database. It is useful when the authenticated user (specified by -U ) lacks privileges needed by pg_restore , but can switch to a role with the required rights. Some installations have a policy against logging in directly as a superuser, and use of this option allows restores to be performed without violating the policy."}],"related":[{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"related_zh":[{"label":"libpq 连接参数","url":"/wiki/conn/?v=18"}],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.7","major":"18","manifest":{"major":"18","release":"18.7","source_sha256":"441dfae4280cae3e0425e5f876f80559fb0731c140f1aae22b3e5a54d0411bfd","source_url":"https://ftp.postgresql.org/pub/source/v18.7/postgresql-18.7.tar.bz2"},"ref":"https://ftp.postgresql.org/pub/source/v18.7/postgresql-18.7.tar.bz2","revision":"1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915","source_sha256":"441dfae4280cae3e0425e5f876f80559fb0731c140f1aae22b3e5a54d0411bfd"},"sections":[],"sections_zh":[],"signature":"pg_restore [ connection-option ...] [ option ...] [ filename ]","sources":[{"anchor":"","file":"app-pgrestore.html","label":"18.7 English manual · app-pgrestore.html","sha256":"c1f6d0d6414421c81071e5fce256cb7d396f6e2922510643d0906263f2ef8dd4","url":"/docs/18/app-pgrestore.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"a1c669b9a6dab81388171b696e61109033d96d2c4d5487219c77f62f14aecfa1","url":"/docs/18/reference-client.html"}],"synopsis":["pg_restore [ connection-option ...] [ option ...] [ filename ]"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-a --data-only","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive."},{"signature":{"text":"-c --clean","url":"/docs/18/app-pgrestore.html"},"summary":"Before restoring database objects, issue commands to DROP all the objects that will be restored. This option is useful for overwriting an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported, unless --if-exists is also specified."},{"signature":{"text":"-C --create","url":"/docs/18/app-pgrestore.html"},"summary":"Create the database before restoring into it. If --clean is also specified, drop and recreate the target database before connecting to it."},{"signature":{"text":"-d dbname --dbname= dbname","url":"/docs/18/app-pgrestore.html"},"summary":"Connect to database dbname and restore directly into the database. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."},{"signature":{"text":"-e --exit-on-error","url":"/docs/18/app-pgrestore.html"},"summary":"Exit if an error is encountered while sending SQL commands to the database. The default is to continue and to display a count of errors at the end of the restoration."},{"signature":{"text":"-f filename --file= filename","url":"/docs/18/app-pgrestore.html"},"summary":"Specify output file for generated script, or for the listing when used with -l . Use - for stdout ."},{"signature":{"text":"-F format --format= format","url":"/docs/18/app-pgrestore.html"},"summary":"Specify format of the archive. It is not necessary to specify the format, since pg_restore will determine the format automatically. If specified, it can be one of the following:"},{"signature":{"text":"-I index --index= index","url":"/docs/18/app-pgrestore.html"},"summary":"Restore definition of named index only. Multiple indexes may be specified with multiple -I switches."},{"signature":{"text":"-j number-of-jobs --jobs= number-of-jobs","url":"/docs/18/app-pgrestore.html"},"summary":"Run the most time-consuming steps of pg_restore — those that load data, create indexes, or create constraints — concurrently, using up to number-of-jobs concurrent sessions. This option can dramatically reduce the time to restore a large database to a server running on a multiprocessor machine. This option is ignored when emitting a script rather than connecting directly to a database server."},{"signature":{"text":"-l --list","url":"/docs/18/app-pgrestore.html"},"summary":"List the table of contents of the archive. The output of this operation can be used as input to the -L option. Note that if filtering switches such as -n or -t are used with -l , they will restrict the items listed."},{"signature":{"text":"-L list-file --use-list= list-file","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only those archive elements that are listed in list-file , and restore them in the order they appear in the file. Note that if filtering switches such as -n or -t are used with -L , they will further restrict the items restored."},{"signature":{"text":"-n schema --schema= schema","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only objects that are in the named schema. Multiple schemas may be specified with multiple -n switches. This can be combined with the -t option to restore just a specific table."},{"signature":{"text":"-N schema --exclude-schema= schema","url":"/docs/18/app-pgrestore.html"},"summary":"Do not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple -N switches."},{"signature":{"text":"-O --no-owner","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O , any user name can be used for the initial connection, and this user will own all the created objects."},{"signature":{"text":"-P function-name(argtype [, ...]) --function= function-name(argtype [, ...])","url":"/docs/18/app-pgrestore.html"},"summary":"Restore the named function only. Be careful to spell the function name and arguments exactly as they appear in the dump file's table of contents. Multiple functions may be specified with multiple -P switches."},{"signature":{"text":"-R --no-reconnect","url":"/docs/18/app-pgrestore.html"},"summary":"This option is obsolete but still accepted for backwards compatibility."},{"signature":{"text":"-s --schema-only","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only the schema (data definitions), not data, to the extent that schema entries are present in the archive."},{"signature":{"text":"-S username --superuser= username","url":"/docs/18/app-pgrestore.html"},"summary":"Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used."},{"signature":{"text":"-t table --table= table","url":"/docs/18/app-pgrestore.html"},"summary":"Restore definition and/or data of only the named table. For this purpose, “ table ” includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. This option can be combined with the -n option to specify table(s) in a particular schema."},{"signature":{"text":"-T trigger --trigger= trigger","url":"/docs/18/app-pgrestore.html"},"summary":"Restore named trigger only. Multiple triggers may be specified with multiple -T switches."},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgrestore.html"},"summary":"Specifies verbose mode. This will cause pg_restore to output detailed object comments and start/stop times to the output file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."},{"signature":{"text":"-V --version","url":"/docs/18/app-pgrestore.html"},"summary":"Print the pg_restore version and exit."},{"signature":{"text":"-x --no-privileges --no-acl","url":"/docs/18/app-pgrestore.html"},"summary":"Prevent restoration of access privileges (grant/revoke commands)."},{"signature":{"text":"-1 --single-transaction","url":"/docs/18/app-pgrestore.html"},"summary":"Execute the restore as a single transaction (that is, wrap the emitted commands in BEGIN / COMMIT ). This ensures that either all the commands complete successfully, or no changes are applied. This option implies --exit-on-error ."},{"signature":{"text":"--disable-triggers","url":"/docs/18/app-pgrestore.html"},"summary":"This option is relevant only when performing a restore without schema. It instructs pg_restore to execute commands to temporarily disable triggers on the target tables while the data is restored. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data restore."},{"signature":{"text":"--enable-row-security","url":"/docs/18/app-pgrestore.html"},"summary":"This option is relevant only when restoring the contents of a table which has row security. By default, pg_restore will set row_security to off, to ensure that all data is restored in to the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_restore to set row_security to on instead, allowing the user to attempt to restore the contents of the table with row security enabled. This might still fail if the user does not have the right to insert the rows from the dump into the table."},{"signature":{"text":"--filter= filename","url":"/docs/18/app-pgrestore.html"},"summary":"Specify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as -n / --schema for including objects in schemas, -N / --exclude-schema for excluding objects in schemas, -P / --function for restoring named functions, -I / --index for restoring named indexes, -t / --table for restoring named tables or -T / --trigger for restoring triggers. To read from STDIN , use - as the filename. The --filter option can be specified in conjunction with the above listed options for including or excluding objects, and can also be specified more than once for multiple filter files."},{"signature":{"text":"--if-exists","url":"/docs/18/app-pgrestore.html"},"summary":"Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses “ does not exist ” errors that might otherwise be reported. This option is not valid unless --clean is also specified."},{"signature":{"text":"--no-comments","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore comments, even if the archive contains them."},{"signature":{"text":"--no-data","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore data, even if the archive contains them."},{"signature":{"text":"--no-data-for-failed-tables","url":"/docs/18/app-pgrestore.html"},"summary":"By default, table data is restored even if the creation command for the table failed (e.g., because it already exists). With this option, data for such a table is skipped. This behavior is useful if the target database already contains the desired table contents. For example, auxiliary tables for PostgreSQL extensions such as PostGIS might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them."},{"signature":{"text":"--no-policies","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore row security policies, even if the archive contains them."},{"signature":{"text":"--no-publications","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore publications, even if the archive contains them."},{"signature":{"text":"--no-schema","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore schema (data definitions), even if the archive contains them."},{"signature":{"text":"--no-security-labels","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore security labels, even if the archive contains them."},{"signature":{"text":"--no-statistics","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore statistics, even if the archive contains them."},{"signature":{"text":"--no-subscriptions","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore subscriptions, even if the archive contains them."},{"signature":{"text":"--no-table-access-method","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to select table access methods. With this option, all objects will be created with whichever table access method is the default during restore."},{"signature":{"text":"--no-tablespaces","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore."},{"signature":{"text":"--restrict-key= restrict_key","url":"/docs/18/app-pgrestore.html"},"summary":"Use the provided string as the psql \\restrict key in the dump output. This can only be specified for SQL script output, i.e., when the --file option is used. If no restrict key is specified, pg_restore will generate a random one as needed. Keys may contain only alphanumeric characters."},{"signature":{"text":"--section= sectionname","url":"/docs/18/app-pgrestore.html"},"summary":"Only restore the named section. The section name can be pre-data , data , or post-data . This option can be specified more than once to select multiple sections. The default is to restore all sections."},{"signature":{"text":"--statistics","url":"/docs/18/app-pgrestore.html"},"summary":"Output commands to restore statistics, if the archive contains them. This is the default."},{"signature":{"text":"--statistics-only","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only the statistics, not schema (data definitions) or data."},{"signature":{"text":"--strict-names","url":"/docs/18/app-pgrestore.html"},"summary":"Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the file to be restored."},{"signature":{"text":"--transaction-size= N","url":"/docs/18/app-pgrestore.html"},"summary":"Execute the restore as a series of transactions, each processing up to N database objects. This option implies --exit-on-error ."},{"signature":{"text":"--use-set-session-authorization","url":"/docs/18/app-pgrestore.html"},"summary":"Output SQL-standard SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to determine object ownership. This makes the dump more standards-compatible, but depending on the history of the objects in the dump, might not restore properly."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgrestore.html"},"summary":"Show help about pg_restore command line arguments, and exit."},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgrestore.html"},"summary":"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 PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgrestore.html"},"summary":"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."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgrestore.html"},"summary":"User name to connect as."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgrestore.html"},"summary":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-pgrestore.html"},"summary":"Force pg_restore to prompt for a password before connecting to a database."},{"signature":{"text":"--role= rolename","url":"/docs/18/app-pgrestore.html"},"summary":"Specifies a role name to be used to perform the restore. This option causes pg_restore to issue a SET ROLE rolename command after connecting to the database. It is useful when the authenticated user (specified by -U ) lacks privileges needed by pg_restore , but can switch to a role with the required rights. Some installations have a policy against logging in directly as a superuser, and use of this option allows restores to be performed without violating the policy."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Default connection parameters","name":"PGHOST PGOPTIONS PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"title":"Environment variables"}],"tables_zh":[{"columns":[{"key":"signature","label":"选项与参数"},{"key":"summary","label":"说明"}],"key":"options","rows":[{"signature":{"text":"-a --data-only","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复数据，不恢复模式（数据定义）或统计信息。如果归档中包含，则会恢复表数据、大对象和序列值。"},{"signature":{"text":"-c --clean","url":"/docs/18/app-pgrestore.html"},"summary":"在恢复数据库对象之前，发出 DROP 命令以删除将要恢复的所有对象。此选项适用于覆盖现有数据库。如果目标数据库中有任何对象不存在，则会报告可忽略的错误消息，除非同时指定了 --if-exists 。"},{"signature":{"text":"-C --create","url":"/docs/18/app-pgrestore.html"},"summary":"在向其中恢复之前先创建数据库。如果同时指定了 --clean ，则会在连接到目标数据库之前先删除并重新创建它。"},{"signature":{"text":"-d dbname --dbname= dbname","url":"/docs/18/app-pgrestore.html"},"summary":"连接到数据库 dbname ，并直接恢复到该数据库中。 dbname 可以是一个 连接字符串 。如果是这样，连接字符串参数会覆盖任何冲突的命令行选项。"},{"signature":{"text":"-e --exit-on-error","url":"/docs/18/app-pgrestore.html"},"summary":"如果在向数据库发送 SQL 命令时遇到错误，则退出。默认行为是继续执行，并在恢复结束时显示错误计数。"},{"signature":{"text":"-f filename --file= filename","url":"/docs/18/app-pgrestore.html"},"summary":"指定生成脚本的输出文件，或者在与 -l 一起使用时指定列表输出文件。使用 - 表示 stdout 。"},{"signature":{"text":"-F format --format= format","url":"/docs/18/app-pgrestore.html"},"summary":"指定归档格式。不必指定格式，因为 pg_restore 会自动确定格式。如果指定，可以是以下格式之一："},{"signature":{"text":"-I index --index= index","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复指定名称的索引的定义。可以通过多次指定 -I 来恢复多个索引。"},{"signature":{"text":"-j number-of-jobs --jobs= number-of-jobs","url":"/docs/18/app-pgrestore.html"},"summary":"将 pg_restore 中最耗时的步骤，也就是装载数据、创建索引或创建约束，最多使用 number-of-jobs 个并发会话并行执行。此选项可以显著缩短将大型数据库恢复到运行在多处理器机器上的服务器所需的时间。当生成脚本而不是直接连接到数据库服务器时，此选项会被忽略。"},{"signature":{"text":"-l --list","url":"/docs/18/app-pgrestore.html"},"summary":"列出归档的目录。此操作的输出可用作 -L 选项的输入。注意，如果将 -n 或 -t 等筛选选项与 -l 一起使用，它们会限制所列出的项目。"},{"signature":{"text":"-L list-file --use-list= list-file","url":"/docs/18/app-pgrestore.html"},"summary":"只恢复 list-file 中列出的归档元素，并按照它们在文件中出现的顺序恢复。注意，如果将 -n 或 -t 等筛选选项与 -L 一起使用，它们会进一步限制所恢复的项目。"},{"signature":{"text":"-n schema --schema= schema","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复位于指定模式中的对象。可以通过多次指定 -n 来指定多个模式。这可以与 -t 选项结合使用，只恢复特定表。"},{"signature":{"text":"-N schema --exclude-schema= schema","url":"/docs/18/app-pgrestore.html"},"summary":"不恢复位于指定模式中的对象。可以通过多次指定 -N 来排除多个模式。"},{"signature":{"text":"-O --no-owner","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于设置对象所有权以匹配原始数据库的命令。默认情况下， pg_restore 会发出 ALTER OWNER 或 SET SESSION AUTHORIZATION 语句，为所创建的模式元素设置所有权。除非对数据库的初始连接由超级用户发起（或者由脚本中所有对象的同一所有者发起），否则这些语句会失败。使用 -O 时，初始连接可以使用任意用户名，并且该用户将拥有所有创建的对象。"},{"signature":{"text":"-P function-name(argtype [, ...]) --function= function-name(argtype [, ...])","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复指定函数。请务必按转储文件目录中显示的形式准确拼写函数名和参数。可以通过多次指定 -P 来恢复多个函数。"},{"signature":{"text":"-R --no-reconnect","url":"/docs/18/app-pgrestore.html"},"summary":"这个选项已经过时，但仍然被接受以保持向后兼容性。"},{"signature":{"text":"-s --schema-only","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复模式（数据定义），不恢复数据，前提是归档中存在模式条目。"},{"signature":{"text":"-S username --superuser= username","url":"/docs/18/app-pgrestore.html"},"summary":"指定在禁用触发器时要使用的超级用户用户名。仅当使用 --disable-triggers 时才相关。"},{"signature":{"text":"-t table --table= table","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复指定表的定义和/或数据。这里的 “ 表 ” 包括视图、物化视图、序列和外部表。可以通过多次指定 -t 来选择多个表。此选项可以与 -n 选项结合使用，以指定特定模式中的表。"},{"signature":{"text":"-T trigger --trigger= trigger","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复指定名称的触发器。可以通过多次指定 -T 来恢复多个触发器。"},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgrestore.html"},"summary":"指定详细模式。这会使 pg_restore 将详细的对象注释和开始/停止时间输出到输出文件，并将进度消息输出到标准错误。重复此选项会使标准错误中出现额外的调试级消息。"},{"signature":{"text":"-V --version","url":"/docs/18/app-pgrestore.html"},"summary":"打印 pg_restore 的版本并退出。"},{"signature":{"text":"-x --no-privileges --no-acl","url":"/docs/18/app-pgrestore.html"},"summary":"不恢复访问权限（grant/revoke 命令）。"},{"signature":{"text":"-1 --single-transaction","url":"/docs/18/app-pgrestore.html"},"summary":"将恢复作为单个事务执行（也就是把发出的命令包裹在 BEGIN / COMMIT 中）。这可确保要么所有命令都成功完成，要么不应用任何更改。此选项隐含 --exit-on-error 。"},{"signature":{"text":"--disable-triggers","url":"/docs/18/app-pgrestore.html"},"summary":"此选项仅在执行不包含模式的恢复时才相关。它会指示 pg_restore 在恢复数据期间发出命令，临时禁用目标表上的触发器。如果你不希望在恢复数据期间触发表上的引用完整性检查或其他触发器，请使用此选项。"},{"signature":{"text":"--enable-row-security","url":"/docs/18/app-pgrestore.html"},"summary":"此选项仅在恢复启用了行安全性的表内容时才相关。默认情况下， pg_restore 会将 row_security 设置为 off，以确保所有数据都能恢复到表中。如果用户没有足够的权限绕过行安全性，就会抛出错误。此参数会指示 pg_restore 改为将 row_security 设置为 on，从而允许用户尝试在启用行安全性的情况下恢复表内容。如果用户无权将转储中的行插入该表，这仍然可能失败。"},{"signature":{"text":"--filter= filename","url":"/docs/18/app-pgrestore.html"},"summary":"指定一个文件名，从中读取恢复时要排除或包含的对象匹配模式。这些模式按照与下列选项相同的规则解释： -n / --schema 用于包含某个模式中的对象， -N / --exclude-schema 用于排除某个模式中的对象， -P / --function 用于恢复指定函数， -I / --index 用于恢复指定索引， -t / --table 用于恢复指定表，以及 -T / --trigger 用于恢复触发器。要从 STDIN 读取，请使用 - 作为文件名。 --filter 选项可以与上面列出的包含或排除对象的选项结合使用，也可以为了指定多个过滤文件而多次给出。"},{"signature":{"text":"--if-exists","url":"/docs/18/app-pgrestore.html"},"summary":"使用 DROP ... IF EXISTS 命令在 --clean 模式下删除对象。这会抑制原本可能报告的 “ does not exist ” 错误信息。除非同时指定了 --clean ，否则此选项无效。"},{"signature":{"text":"--no-comments","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复注释的命令，即使归档中包含注释。"},{"signature":{"text":"--no-data","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复数据的命令，即使归档中包含数据。"},{"signature":{"text":"--no-data-for-failed-tables","url":"/docs/18/app-pgrestore.html"},"summary":"默认情况下，即使表的创建命令失败（例如因为表已经存在），表数据仍然会被恢复。使用此选项时，这类表的数据会被跳过。如果目标数据库已经包含所需的表内容，这种行为会很有用。例如， PostgreSQL 扩展（如 PostGIS ）的辅助表可能已经装载到目标数据库中；指定此选项可以防止向这些表装载重复或过时的数据。"},{"signature":{"text":"--no-policies","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复行安全性策略的命令，即使归档中包含它们。"},{"signature":{"text":"--no-publications","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复发布的命令，即使归档中包含它们。"},{"signature":{"text":"--no-schema","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复模式（数据定义）的命令，即使归档中包含它们。"},{"signature":{"text":"--no-security-labels","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复安全标签的命令，即使归档中包含它们。"},{"signature":{"text":"--no-statistics","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复统计信息的命令，即使归档中包含它们。"},{"signature":{"text":"--no-subscriptions","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于恢复订阅的命令，即使归档中包含它们。"},{"signature":{"text":"--no-table-access-method","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于选择表访问方法的命令。使用此选项时，所有对象在恢复时都会使用当时默认的表访问方法创建。"},{"signature":{"text":"--no-tablespaces","url":"/docs/18/app-pgrestore.html"},"summary":"不输出用于选择表空间的命令。使用此选项时，所有对象在恢复时都会创建在当时默认的表空间中。"},{"signature":{"text":"--restrict-key= restrict_key","url":"/docs/18/app-pgrestore.html"},"summary":"在转储输出中使用提供的字符串作为 psql \\restrict 键。这只能用于 SQL 脚本输出，也就是使用 --file 选项时。如果未指定该键， pg_restore 会按需随机生成一个。键只能包含字母数字字符。"},{"signature":{"text":"--section= sectionname","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复指定部分。部分名称可以是 pre-data 、 data 或 post-data 。可以多次指定此选项来选择多个部分。默认是恢复所有部分。"},{"signature":{"text":"--statistics","url":"/docs/18/app-pgrestore.html"},"summary":"如果归档中包含统计信息，则输出用于恢复统计信息的命令。这是默认行为。"},{"signature":{"text":"--statistics-only","url":"/docs/18/app-pgrestore.html"},"summary":"仅恢复统计信息，不恢复模式（数据定义）或数据。"},{"signature":{"text":"--strict-names","url":"/docs/18/app-pgrestore.html"},"summary":"要求每个模式限定符（ -n / --schema ）和表限定符（ -t / --table ）至少匹配待恢复文件中的一个模式/表。"},{"signature":{"text":"--transaction-size= N","url":"/docs/18/app-pgrestore.html"},"summary":"将恢复作为一系列事务执行，每个事务最多处理 N 个数据库对象。此选项隐含 --exit-on-error 。"},{"signature":{"text":"--use-set-session-authorization","url":"/docs/18/app-pgrestore.html"},"summary":"输出符合 SQL 标准的 SET SESSION AUTHORIZATION 命令，而不是使用 ALTER OWNER 命令来确定对象所有权。这样会使转储结果更符合标准，但根据转储中对象的历史，可能无法正确恢复。"},{"signature":{"text":"-? --help","url":"/docs/18/app-pgrestore.html"},"summary":"显示关于 pg_restore 命令行参数的帮助信息，并退出。"},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgrestore.html"},"summary":"指定服务器所在机器的主机名。如果值以斜杠开头，则被用作 Unix 域套接字的目录。默认值取自 PGHOST 环境变量（如果已设置），否则尝试使用 Unix 域套接字连接。"},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgrestore.html"},"summary":"指定服务器正在监听连接的 TCP 端口，或本地 Unix 域套接字文件扩展名。默认值取自 PGPORT 环境变量（如果已设置），否则使用编译时默认值。"},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgrestore.html"},"summary":"用于连接的用户名。"},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgrestore.html"},"summary":"绝不发出密码提示。如果服务器要求密码认证，而又无法通过 .pgpass 文件等其他方式获得密码，则连接尝试将失败。在没有用户在场输入密码的批处理作业和脚本中，此选项很有用。"},{"signature":{"text":"-W --password","url":"/docs/18/app-pgrestore.html"},"summary":"强制 pg_restore 在连接数据库之前提示输入密码。"},{"signature":{"text":"--role= rolename","url":"/docs/18/app-pgrestore.html"},"summary":"指定执行恢复时要使用的角色名。此选项会使 pg_restore 在连接数据库后发出 SET ROLE rolename 命令。当已认证用户（由 -U 指定）缺少 pg_restore 所需的权限，但可以切换到具有所需权限的角色时，此选项会很有用。有些安装环境禁止直接以超级用户登录，而使用此选项可以在不违反该策略的情况下执行恢复。"}],"title":"手册中的选项"},{"columns":[{"key":"name","label":"变量"},{"key":"description","label":"含义"}],"key":"environment","rows":[{"description":"默认连接参数","name":"PGHOST PGOPTIONS PGPORT PGUSER"},{"description":"指定诊断消息是否使用颜色。可选值为 always 、 auto 和 never 。","name":"PG_COLOR"}],"title":"环境变量"}],"zh_from":"same-version-manual"},"ManualEvidence":{"manual_path":"app-pgrestore.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.7","major":"18","manifest":{"major":"18","release":"18.7","source_sha256":"441dfae4280cae3e0425e5f876f80559fb0731c140f1aae22b3e5a54d0411bfd","source_url":"https://ftp.postgresql.org/pub/source/v18.7/postgresql-18.7.tar.bz2"},"ref":"https://ftp.postgresql.org/pub/source/v18.7/postgresql-18.7.tar.bz2","revision":"1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915","source_sha256":"441dfae4280cae3e0425e5f876f80559fb0731c140f1aae22b3e5a54d0411bfd"},"sources":[{"anchor":"","file":"app-pgrestore.html","label":"18.7 English manual · app-pgrestore.html","sha256":"c1f6d0d6414421c81071e5fce256cb7d396f6e2922510643d0906263f2ef8dd4","url":"/docs/18/app-pgrestore.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"a1c669b9a6dab81388171b696e61109033d96d2c4d5487219c77f62f14aecfa1","url":"/docs/18/reference-client.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"pg-restore","SourceDatabase":"center","Version":"18","Locale":"en","Title":"pg_restore","Summary":"pg_restore — restore a PostgreSQL database from an archive file created by pg_dump","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"APP-PGRESTORE\"\u003e\u003cdiv\u003e\u003c/div\u003e\u003cdiv\u003e\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epg_restore\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\u003cp\u003epg_restore — \n   restore a \u003cspan\u003ePostgreSQL\u003c/span\u003e database from an\n   archive file created by \u003cspan\u003epg_dump\u003c/span\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv\u003e\u003ch2\u003eSynopsis\u003c/h2\u003e\u003cdiv\u003e\u003cp id=\"id-1.9.4.19.4.1\"\u003e\u003ccode\u003epg_restore\u003c/code\u003e [\u003cem\u003e\u003ccode\u003econnection-option\u003c/code\u003e\u003c/em\u003e...] [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv id=\"APP-PGRESTORE-DESCRIPTION\"\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\n\u003cspan\u003epg_restore\u003c/span\u003e is a utility for restoring a\n   \u003cspan\u003ePostgreSQL\u003c/span\u003e database from an archive\n   created by \u003ca href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e in one of the non-plain-text\n   formats.  It will issue the commands necessary to reconstruct the\n   database to the state it was in at the time it was saved.  The\n   archive files also allow \u003cspan\u003epg_restore\u003c/span\u003e to\n   be selective about what is restored, or even to reorder the items\n   prior to being restored. The archive files are designed to be\n   portable across architectures.\n  \u003c/p\u003e\u003cp\u003e\n\u003cspan\u003epg_restore\u003c/span\u003e can operate in two modes.\n   If a database name is specified, \u003cspan\u003epg_restore\u003c/span\u003e\n   connects to that database and restores archive contents directly into\n   the database.  Otherwise, a script containing the SQL\n   commands necessary to rebuild the database is created and written\n   to a file or standard output.  This script output is equivalent to\n   the plain text output format of \u003cspan\u003epg_dump\u003c/span\u003e.\n   Some of the options controlling the output are therefore analogous to\n   \u003cspan\u003epg_dump\u003c/span\u003e options.\n  \u003c/p\u003e\u003cp\u003e\n   Obviously, \u003cspan\u003epg_restore\u003c/span\u003e cannot restore information\n   that is not present in the archive file.  For instance, if the\n   archive was made using the \u003cspan\u003e“\u003cspan\u003edump data as\n   \u003ccode\u003eINSERT\u003c/code\u003e commands\u003c/span\u003e”\u003c/span\u003e option,\n   \u003cspan\u003epg_restore\u003c/span\u003e will not be able to load the data\n   using \u003ccode\u003eCOPY\u003c/code\u003e statements.\n  \u003c/p\u003e\u003cdiv\u003e\u003ch3\u003eWarning\u003c/h3\u003e\u003cp\u003e\n    Restoring a dump causes the destination to execute arbitrary code of the\n    source superusers\u0026#39; choice.  Partial dumps and partial restores do not limit\n    that.  If the source superusers are not trusted, the dumped SQL statements\n    must be inspected before restoring.  Non-plain-text dumps can be inspected\n    by using \u003cspan\u003epg_restore\u003c/span\u003e\u0026#39;s \u003ccode\u003e--file\u003c/code\u003e\n    option.  Note that the client running the dump and restore need not trust\n    the source or destination superusers.\n   \u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv id=\"APP-PGRESTORE-OPTIONS\"\u003e\u003ch2\u003eOptions\u003c/h2\u003e\u003cp\u003e\n\u003cspan\u003epg_restore\u003c/span\u003e accepts the following command\n    line arguments.\n\n    \u003c/p\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Specifies the location of the archive file (or directory, for a\n       directory-format archive) to be restored.\n       If not specified, the standard input is used.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-a\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--data-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the data, not the schema (data definitions) or statistics.\n        Table data, large objects, and sequence values are restored,\n        if present in the archive.\n       \u003c/p\u003e\u003cp\u003e\n        This option is similar to, but for historical reasons not identical\n        to, specifying \u003ccode\u003e--section=data\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-c\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--clean\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Before restoring database objects, issue commands\n        to \u003ccode\u003eDROP\u003c/code\u003e all the objects that will be restored.\n        This option is useful for overwriting an existing database.\n        If any of the objects do not exist in the destination database,\n        ignorable error messages will be reported,\n        unless \u003ccode\u003e--if-exists\u003c/code\u003e is also specified.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--create\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Create the database before restoring into it.\n        If \u003ccode\u003e--clean\u003c/code\u003e is also specified, drop and\n        recreate the target database before connecting to it.\n       \u003c/p\u003e\u003cp\u003e\n        With \u003ccode\u003e--create\u003c/code\u003e, \u003cspan\u003epg_restore\u003c/span\u003e\n        also restores the database\u0026#39;s comment if any, and any configuration\n        variable settings that are specific to this database, that is,\n        any \u003ccode\u003eALTER DATABASE ... SET ...\u003c/code\u003e\n        and \u003ccode\u003eALTER ROLE ... IN DATABASE ... SET ...\u003c/code\u003e\n        commands that mention this database.\n        Access privileges for the database itself are also restored,\n        unless \u003ccode\u003e--no-acl\u003c/code\u003e is specified.\n       \u003c/p\u003e\u003cp\u003e\n        When this option is used, the database named with \u003ccode\u003e-d\u003c/code\u003e\n        is used only to issue the initial \u003ccode\u003eDROP DATABASE\u003c/code\u003e and\n        \u003ccode\u003eCREATE DATABASE\u003c/code\u003e commands.  All data is restored into the\n        database name that appears in the archive.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-d \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--dbname=\u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Connect to database \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e and restore directly\n        into the database.  The \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can\n        be a \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" rel=\"nofollow\"\u003econnection string\u003c/a\u003e.\n        If so, connection string parameters will override any conflicting\n        command line options.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--exit-on-error\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Exit if an error is encountered while sending SQL commands to\n        the database. The default is to continue and to display a count of\n        errors at the end of the restoration.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-f \u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--file=\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify output file for generated script, or for the listing\n        when used with \u003ccode\u003e-l\u003c/code\u003e. Use \u003ccode\u003e-\u003c/code\u003e\n        for \u003cspan\u003estdout\u003c/span\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-F \u003cem\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--format=\u003cem\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify format of the archive.  It is not necessary to specify\n        the format, since \u003cspan\u003epg_restore\u003c/span\u003e will\n        determine the format automatically. If specified, it can be\n        one of the following:\n\n       \u003c/p\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ec\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ecustom\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is in the custom format of\n           \u003cspan\u003epg_dump\u003c/span\u003e.\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ed\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is a directory archive.\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003et\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003etar\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is a \u003ccode\u003etar\u003c/code\u003e archive.\n          \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-I \u003cem\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--index=\u003cem\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore definition of named index only.  Multiple indexes\n        may be specified with multiple \u003ccode\u003e-I\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-j \u003cem\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--jobs=\u003cem\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Run the most time-consuming steps\n        of \u003cspan\u003epg_restore\u003c/span\u003e — those that load data,\n        create indexes, or create constraints — concurrently, using up\n        to \u003cem\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\n        concurrent sessions.  This option can dramatically reduce the time\n        to restore a large database to a server running on a\n        multiprocessor machine.  This option is ignored when emitting a script\n        rather than connecting directly to a database server.\n       \u003c/p\u003e\u003cp\u003e\n        Each job is one process or one thread, depending on the\n        operating system, and uses a separate connection to the\n        server.\n       \u003c/p\u003e\u003cp\u003e\n        The optimal value for this option depends on the hardware\n        setup of the server, of the client, and of the network.\n        Factors include the number of CPU cores and the disk setup.  A\n        good place to start is the number of CPU cores on the server,\n        but values larger than that can also lead to faster restore\n        times in many cases.  Of course, values that are too high will\n        lead to decreased performance because of thrashing.\n       \u003c/p\u003e\u003cp\u003e\n        Only the custom and directory archive formats are supported\n        with this option.\n        The input must be a regular file or directory (not, for example, a\n        pipe or standard input).  Also, multiple\n        jobs cannot be used together with the\n        option \u003ccode\u003e--single-transaction\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--list\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        List the table of contents of the archive. The output of this operation\n        can be used as input to the \u003ccode\u003e-L\u003c/code\u003e option.  Note that\n        if filtering switches such as \u003ccode\u003e-n\u003c/code\u003e or \u003ccode\u003e-t\u003c/code\u003e are\n        used with \u003ccode\u003e-l\u003c/code\u003e, they will restrict the items listed.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-L \u003cem\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--use-list=\u003cem\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only those archive elements that are listed in \u003cem\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e, and restore them in the\n        order they appear in the file.  Note that\n        if filtering switches such as \u003ccode\u003e-n\u003c/code\u003e or \u003ccode\u003e-t\u003c/code\u003e are\n        used with \u003ccode\u003e-L\u003c/code\u003e, they will further restrict the items restored.\n       \u003c/p\u003e\u003cp\u003e\u003cem\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e is normally created by\n        editing the output of a previous \u003ccode\u003e-l\u003c/code\u003e operation.\n        Lines can be moved or removed, and can also\n        be commented out by placing a semicolon (\u003ccode\u003e;\u003c/code\u003e) at the\n        start of the line.  See below for examples.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-n \u003cem\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--schema=\u003cem\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only objects that are in the named schema.  Multiple schemas\n        may be specified with multiple \u003ccode\u003e-n\u003c/code\u003e switches.  This can be\n        combined with the \u003ccode\u003e-t\u003c/code\u003e option to restore just a\n        specific table.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-N \u003cem\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--exclude-schema=\u003cem\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not restore objects that are in the named schema.  Multiple schemas\n        to be excluded may be specified with multiple \u003ccode\u003e-N\u003c/code\u003e switches.\n       \u003c/p\u003e\u003cp\u003e\n        When both \u003ccode\u003e-n\u003c/code\u003e and \u003ccode\u003e-N\u003c/code\u003e are given for the same\n        schema name, the \u003ccode\u003e-N\u003c/code\u003e switch wins and the schema is excluded.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-O\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-owner\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to set\n        ownership of objects to match the original database.\n        By default, \u003cspan\u003epg_restore\u003c/span\u003e issues\n        \u003ccode\u003eALTER OWNER\u003c/code\u003e or\n        \u003ccode\u003eSET SESSION AUTHORIZATION\u003c/code\u003e\n        statements to set ownership of created schema elements.\n        These statements will fail unless the initial connection to the\n        database is made by a superuser\n        (or the same user that owns all of the objects in the script).\n        With \u003ccode\u003e-O\u003c/code\u003e, any user name can be used for the\n        initial connection, and this user will own all the created objects.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-P \u003cem\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--function=\u003cem\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore the named function only.  Be careful to spell the function\n        name and arguments exactly as they appear in the dump file\u0026#39;s table\n        of contents.  Multiple functions may be specified with multiple\n        \u003ccode\u003e-P\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-R\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-reconnect\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is obsolete but still accepted for backwards\n        compatibility.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--schema-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the schema (data definitions), not data,\n        to the extent that schema entries are present in the archive.\n       \u003c/p\u003e\u003cp\u003e\n        This option cannot be used with \u003ccode\u003e--data-only\u003c/code\u003e\n        or \u003ccode\u003e--statistics-only\u003c/code\u003e.\n        It is similar to, but for historical reasons not identical to,\n        specifying\n        \u003ccode\u003e--section=pre-data --section=post-data --no-statistics\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n        (Do not confuse this with the \u003ccode\u003e--schema\u003c/code\u003e option, which\n        uses the word \u003cspan\u003e“\u003cspan\u003eschema\u003c/span\u003e”\u003c/span\u003e in a different meaning.)\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-S \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--superuser=\u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify the superuser user name to use when disabling triggers.\n        This is relevant only if \u003ccode\u003e--disable-triggers\u003c/code\u003e is used.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-t \u003cem\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--table=\u003cem\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore definition and/or data of only the named table.\n        For this purpose, \u003cspan\u003e“\u003cspan\u003etable\u003c/span\u003e”\u003c/span\u003e includes views, materialized views,\n        sequences, and foreign tables.  Multiple tables\n        can be selected by writing multiple \u003ccode\u003e-t\u003c/code\u003e switches.\n        This option can be combined with the \u003ccode\u003e-n\u003c/code\u003e option to\n        specify table(s) in a particular schema.\n       \u003c/p\u003e\u003cdiv\u003e\u003ch3\u003eNote\u003c/h3\u003e\u003cp\u003e\n         When \u003ccode\u003e-t\u003c/code\u003e is specified, \u003cspan\u003epg_restore\u003c/span\u003e\n         makes no attempt to restore any other database objects that the\n         selected table(s) might depend upon.  Therefore, there is no\n         guarantee that a specific-table restore into a clean database will\n         succeed.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv\u003e\u003ch3\u003eNote\u003c/h3\u003e\u003cp\u003e\n         This flag does not behave identically to the \u003ccode\u003e-t\u003c/code\u003e\n         flag of \u003cspan\u003epg_dump\u003c/span\u003e.  There is not currently\n         any provision for wild-card matching in \u003cspan\u003epg_restore\u003c/span\u003e,\n         nor can you include a schema name within its \u003ccode\u003e-t\u003c/code\u003e.\n         And, while \u003cspan\u003epg_dump\u003c/span\u003e\u0026#39;s \u003ccode\u003e-t\u003c/code\u003e\n         flag will also dump subsidiary objects (such as indexes) of the\n         selected table(s),\n         \u003cspan\u003epg_restore\u003c/span\u003e\u0026#39;s \u003ccode\u003e-t\u003c/code\u003e\n         flag does not include such subsidiary objects.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv\u003e\u003ch3\u003eNote\u003c/h3\u003e\u003cp\u003e\n         In versions prior to \u003cspan\u003ePostgreSQL\u003c/span\u003e 9.6, this flag\n         matched only tables, not any other type of relation.\n        \u003c/p\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-T \u003cem\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--trigger=\u003cem\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore named trigger only.  Multiple triggers may be specified with\n        multiple \u003ccode\u003e-T\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies verbose mode.  This will cause\n        \u003cspan\u003epg_restore\u003c/span\u003e to output detailed object\n        comments and start/stop times to the output file, and progress\n        messages to standard error.\n        Repeating the option causes additional debug-level messages\n        to appear on standard error.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Print the \u003cspan\u003epg_restore\u003c/span\u003e version and exit.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-x\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-privileges\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-acl\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Prevent restoration of access privileges (grant/revoke commands).\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--single-transaction\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Execute the restore as a single transaction (that is, wrap the\n        emitted commands in \u003ccode\u003eBEGIN\u003c/code\u003e/\u003ccode\u003eCOMMIT\u003c/code\u003e).  This\n        ensures that either all the commands complete successfully, or no\n        changes are applied. This option implies\n        \u003ccode\u003e--exit-on-error\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--disable-triggers\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is relevant only when performing a restore without schema.\n        It instructs \u003cspan\u003epg_restore\u003c/span\u003e to execute commands\n        to temporarily disable triggers on the target tables while\n        the data is restored.  Use this if you have referential\n        integrity checks or other triggers on the tables that you\n        do not want to invoke during data restore.\n       \u003c/p\u003e\u003cp\u003e\n        Presently, the commands emitted for\n        \u003ccode\u003e--disable-triggers\u003c/code\u003e must be done as superuser.  So you\n        should also specify a superuser name with \u003ccode\u003e-S\u003c/code\u003e or,\n        preferably, run \u003cspan\u003epg_restore\u003c/span\u003e as a\n        \u003cspan\u003ePostgreSQL\u003c/span\u003e superuser.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--enable-row-security\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is relevant only when restoring the contents of a table\n        which has row security.  By default, \u003cspan\u003epg_restore\u003c/span\u003e will set\n        \u003ca href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\" rel=\"nofollow\"\u003erow_security\u003c/a\u003e to off, to ensure\n        that all data is restored in to the table.  If the user does not have\n        sufficient privileges to bypass row security, then an error is thrown.\n        This parameter instructs \u003cspan\u003epg_restore\u003c/span\u003e to set\n        \u003ca href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\" rel=\"nofollow\"\u003erow_security\u003c/a\u003e to on instead, allowing the user to attempt to restore\n        the contents of the table with row security enabled.  This might still\n        fail if the user does not have the right to insert the rows from the\n        dump into the table.\n       \u003c/p\u003e\u003cp\u003e\n        Note that this option currently also requires the dump be in \u003ccode\u003eINSERT\u003c/code\u003e\n        format, as \u003ccode\u003eCOPY FROM\u003c/code\u003e does not support row security.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--filter=\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify a filename from which to read patterns for objects excluded\n        or included from restore. The patterns are interpreted according to the\n        same rules as\n        \u003ccode\u003e-n\u003c/code\u003e/\u003ccode\u003e--schema\u003c/code\u003e for including objects in schemas,\n        \u003ccode\u003e-N\u003c/code\u003e/\u003ccode\u003e--exclude-schema\u003c/code\u003e for excluding objects in schemas,\n        \u003ccode\u003e-P\u003c/code\u003e/\u003ccode\u003e--function\u003c/code\u003e for restoring named functions,\n        \u003ccode\u003e-I\u003c/code\u003e/\u003ccode\u003e--index\u003c/code\u003e for restoring named indexes,\n        \u003ccode\u003e-t\u003c/code\u003e/\u003ccode\u003e--table\u003c/code\u003e for restoring named tables\n        or \u003ccode\u003e-T\u003c/code\u003e/\u003ccode\u003e--trigger\u003c/code\u003e for restoring triggers.\n        To read from \u003ccode\u003eSTDIN\u003c/code\u003e, use \u003ccode\u003e-\u003c/code\u003e as the\n        filename.  The \u003ccode\u003e--filter\u003c/code\u003e option can be specified in\n        conjunction with the above listed options for including or excluding\n        objects, and can also be specified more than once for multiple filter\n        files.\n       \u003c/p\u003e\u003cp\u003e\n        The file lists one database pattern per row, with the following format:\n\u003c/p\u003e\u003cpre\u003e{ include | exclude } { function | index | schema | table | trigger } \u003cem\u003e\u003ccode\u003ePATTERN\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        The first keyword specifies whether the objects matched by the pattern\n        are to be included or excluded. The second keyword specifies the type\n        of object to be filtered using the pattern:\n        \u003c/p\u003e\u003cdiv\u003e\u003cul\u003e\u003cli\u003e\u003cp\u003e\n\u003ccode\u003efunction\u003c/code\u003e: functions, works like the\n           \u003ccode\u003e-P\u003c/code\u003e/\u003ccode\u003e--function\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e\n\u003ccode\u003eindex\u003c/code\u003e: indexes, works like the\n           \u003ccode\u003e-I\u003c/code\u003e/\u003ccode\u003e--index\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e\n\u003ccode\u003eschema\u003c/code\u003e: schemas, works like the\n           \u003ccode\u003e-n\u003c/code\u003e/\u003ccode\u003e--schema\u003c/code\u003e and\n           \u003ccode\u003e-N\u003c/code\u003e/\u003ccode\u003e--exclude-schema\u003c/code\u003e options.\n          \u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e\n\u003ccode\u003etable\u003c/code\u003e: tables, works like the\n           \u003ccode\u003e-t\u003c/code\u003e/\u003ccode\u003e--table\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e\n\u003ccode\u003etrigger\u003c/code\u003e: triggers, works like the\n           \u003ccode\u003e-T\u003c/code\u003e/\u003ccode\u003e--trigger\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        Lines starting with \u003ccode\u003e#\u003c/code\u003e are considered comments and\n        ignored. Comments can be placed after an object pattern row as well.\n        Blank lines are also ignored. See \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003ePatterns\u003c/a\u003e\n        for how to perform quoting in patterns.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--if-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Use \u003ccode\u003eDROP ... IF EXISTS\u003c/code\u003e commands to drop objects\n        in \u003ccode\u003e--clean\u003c/code\u003e mode.  This suppresses \u003cspan\u003e“\u003cspan\u003edoes not\n        exist\u003c/span\u003e”\u003c/span\u003e errors that might otherwise be reported.  This\n        option is not valid unless \u003ccode\u003e--clean\u003c/code\u003e is also\n        specified.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-comments\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore comments, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-data\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore data, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-data-for-failed-tables\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        By default, table data is restored even if the creation command\n        for the table failed (e.g., because it already exists).\n        With this option, data for such a table is skipped.\n        This behavior is useful if the target database already\n        contains the desired table contents.  For example,\n        auxiliary tables for \u003cspan\u003ePostgreSQL\u003c/span\u003e extensions\n        such as \u003cspan\u003ePostGIS\u003c/span\u003e might already be loaded in\n        the target database; specifying this option prevents duplicate\n        or obsolete data from being loaded into them.\n       \u003c/p\u003e\u003cp\u003e\n        This option is effective only when restoring directly into a\n        database, not when producing SQL script output.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-policies\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore row security policies, even if\n        the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-publications\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore publications, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-schema\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore schema (data definitions), even if\n        the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-security-labels\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore security labels,\n        even if the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore statistics, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-subscriptions\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore subscriptions, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-table-access-method\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to select table access methods.\n        With this option, all objects will be created with whichever\n        table access method is the default during restore.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-tablespaces\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to select tablespaces.\n        With this option, all objects will be created in whichever\n        tablespace is the default during restore.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--restrict-key=\u003cem\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Use the provided string as the \u003cspan\u003epsql\u003c/span\u003e\n\u003ccode\u003e\\restrict\u003c/code\u003e key in the dump output.  This can only be\n        specified for SQL script output, i.e., when the \u003ccode\u003e--file\u003c/code\u003e\n        option is used.  If no restrict key is specified,\n        \u003cspan\u003epg_restore\u003c/span\u003e will generate a random one as\n        needed.  Keys may contain only alphanumeric characters.\n       \u003c/p\u003e\u003cp\u003e\n        This option is primarily intended for testing purposes and other\n        scenarios that require repeatable output (e.g., comparing dump files).\n        It is not recommended for general use, as a malicious server with\n        advance knowledge of the key may be able to inject arbitrary code that\n        will be executed on the machine that runs\n        \u003cspan\u003epsql\u003c/span\u003e with the dump output.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--section=\u003cem\u003e\u003ccode\u003esectionname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n          Only restore the named section. The section name can be\n          \u003ccode\u003epre-data\u003c/code\u003e, \u003ccode\u003edata\u003c/code\u003e, or \u003ccode\u003epost-data\u003c/code\u003e.\n          This option can be specified more than once to select multiple\n          sections. The default is to restore all sections.\n         \u003c/p\u003e\u003cp\u003e\n          The data section contains actual table data as well as large-object\n          definitions.\n          Post-data items consist of definitions of indexes, triggers, rules\n          and constraints other than validated check constraints.\n          Pre-data items consist of all other data definition items.\n         \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Output commands to restore statistics, if the archive contains them.\n        This is the default.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--statistics-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the statistics, not schema (data definitions) or data.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--strict-names\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Require that each schema\n        (\u003ccode\u003e-n\u003c/code\u003e/\u003ccode\u003e--schema\u003c/code\u003e) and table\n        (\u003ccode\u003e-t\u003c/code\u003e/\u003ccode\u003e--table\u003c/code\u003e) qualifier match at\n        least one schema/table in the file to be restored.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--transaction-size=\u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Execute the restore as a series of transactions, each processing\n        up to \u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e database\n        objects.  This option implies \u003ccode\u003e--exit-on-error\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n\u003ccode\u003e--transaction-size\u003c/code\u003e offers an intermediate choice\n        between the default behavior (one transaction per SQL command)\n        and \u003ccode\u003e-1\u003c/code\u003e/\u003ccode\u003e--single-transaction\u003c/code\u003e\n        (one transaction for all restored objects).\n        While \u003ccode\u003e--single-transaction\u003c/code\u003e has the least\n        overhead, it may be impractical for large databases because the\n        transaction will take a lock on each restored object, possibly\n        exhausting the server\u0026#39;s lock table space.\n        Using \u003ccode\u003e--transaction-size\u003c/code\u003e with a size of a few\n        thousand objects offers nearly the same performance benefits while\n        capping the amount of lock table space needed.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--use-set-session-authorization\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Output SQL-standard \u003ccode\u003eSET SESSION AUTHORIZATION\u003c/code\u003e commands\n        instead of \u003ccode\u003eALTER OWNER\u003c/code\u003e commands to determine object\n        ownership.  This makes the dump more standards-compatible, but\n        depending on the history of the objects in the dump, might not restore\n        properly.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Show help about \u003cspan\u003epg_restore\u003c/span\u003e command line\n       arguments, and exit.\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n\u003cspan\u003epg_restore\u003c/span\u003e also accepts\n    the following command line arguments for connection parameters:\n\n    \u003c/p\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-h \u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--host=\u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies the host name of the machine on which the server is\n        running.  If the value begins with a slash, it is used as the\n        directory for the Unix domain socket. The default is taken\n        from the \u003ccode\u003ePGHOST\u003c/code\u003e environment variable, if set,\n        else a Unix domain socket connection is attempted.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-p \u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--port=\u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies the TCP port or local Unix domain socket file\n        extension on which the server is listening for connections.\n        Defaults to the \u003ccode\u003ePGPORT\u003c/code\u003e environment variable, if\n        set, or a compiled-in default.\n        \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-U \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--username=\u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        User name to connect as.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Never issue a password prompt.  If the server requires\n        password authentication and a password is not available by\n        other means such as a \u003ccode\u003e.pgpass\u003c/code\u003e file, the\n        connection attempt will fail.  This option can be useful in\n        batch jobs and scripts where no user is present to enter a\n        password.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Force \u003cspan\u003epg_restore\u003c/span\u003e to prompt for a\n        password before connecting to a database.\n       \u003c/p\u003e\u003cp\u003e\n        This option is never essential, since\n        \u003cspan\u003epg_restore\u003c/span\u003e will automatically prompt\n        for a password if the server demands password authentication.\n        However, \u003cspan\u003epg_restore\u003c/span\u003e will waste a\n        connection attempt finding out that the server wants a password.\n        In some cases it is worth typing \u003ccode\u003e-W\u003c/code\u003e to avoid the extra\n        connection attempt.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--role=\u003cem\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies a role name to be used to perform the restore.\n        This option causes \u003cspan\u003epg_restore\u003c/span\u003e to issue a\n        \u003ccode\u003eSET ROLE\u003c/code\u003e \u003cem\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e\n        command after connecting to the database. It is useful when the\n        authenticated user (specified by \u003ccode\u003e-U\u003c/code\u003e) lacks privileges\n        needed by \u003cspan\u003epg_restore\u003c/span\u003e, but can switch to a role with\n        the required rights.  Some installations have a policy against\n        logging in directly as a superuser, and use of this option allows\n        restores to be performed without violating the policy.\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"id-1.9.4.19.7\"\u003e\u003ch2\u003eEnvironment\u003c/h2\u003e\u003cdiv\u003e\u003cdl\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGOPTIONS\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003ePGUSER\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      Default connection parameters\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      Specifies whether to use color in diagnostic messages. Possible values\n      are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and\n      \u003ccode\u003enever\u003c/code\u003e.\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n   This utility, like most other \u003cspan\u003ePostgreSQL\u003c/span\u003e utilities,\n   also uses the environment variables supported by \u003cspan\u003elibpq\u003c/span\u003e\n   (see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e).  However, it does not read\n   \u003ccode\u003ePGDATABASE\u003c/code\u003e when a database name is not supplied.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"APP-PGRESTORE-DIAGNOSTICS\"\u003e\u003ch2\u003eDiagnostics\u003c/h2\u003e\u003cp\u003e\n   When a direct database connection is specified using the\n   \u003ccode\u003e-d\u003c/code\u003e option, \u003cspan\u003epg_restore\u003c/span\u003e\n   internally executes SQL statements. If you have\n   problems running \u003cspan\u003epg_restore\u003c/span\u003e, make sure\n   you are able to select information from the database using, for\n   example, \u003ca href=\"/docs/18/app-psql.html\" title=\"psql\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e.  Also, any default connection\n   settings and environment variables used by the\n   \u003cspan\u003elibpq\u003c/span\u003e front-end library will apply.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"APP-PGRESTORE-NOTES\"\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003e\n   If your installation has any local additions to the\n   \u003ccode\u003etemplate1\u003c/code\u003e database, be careful to load the output of\n   \u003cspan\u003epg_restore\u003c/span\u003e into a truly empty database;\n   otherwise you are likely to get errors due to duplicate definitions\n   of the added objects.  To make an empty database without any local\n   additions, copy from \u003ccode\u003etemplate0\u003c/code\u003e not \u003ccode\u003etemplate1\u003c/code\u003e, for example:\n\u003c/p\u003e\u003cpre\u003eCREATE DATABASE foo WITH TEMPLATE template0;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   The limitations of \u003cspan\u003epg_restore\u003c/span\u003e are detailed below.\n\n   \u003c/p\u003e\u003cdiv\u003e\u003cul\u003e\u003cli\u003e\u003cp\u003e\n      When restoring data to a pre-existing table and the option\n      \u003ccode\u003e--disable-triggers\u003c/code\u003e is used,\n      \u003cspan\u003epg_restore\u003c/span\u003e emits commands\n      to disable triggers on user tables before inserting the data, then emits commands to\n      re-enable them after the data has been inserted.  If the restore is stopped in the\n      middle, the system catalogs might be left in the wrong state.\n     \u003c/p\u003e\u003c/li\u003e\u003cli\u003e\u003cp\u003e\u003cspan\u003epg_restore\u003c/span\u003e cannot restore large objects\n      selectively;  for instance, only those for a specific table.  If\n      an archive contains large objects, then all large objects will be\n      restored, or none of them if they are excluded via \u003ccode\u003e-L\u003c/code\u003e,\n      \u003ccode\u003e-t\u003c/code\u003e, or other options.\n     \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   See also the \u003ca href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e documentation for details on\n   limitations of \u003cspan\u003epg_dump\u003c/span\u003e.\n  \u003c/p\u003e\u003cp\u003e\n   By default, \u003ccode\u003epg_restore\u003c/code\u003e will restore optimizer statistics\n   if included in the dump file.  If not all statistics were restored, it may\n   be useful to run \u003ccode\u003eANALYZE\u003c/code\u003e on each restored table so the\n   optimizer has useful statistics; see \u003ca href=\"/docs/18/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" rel=\"nofollow\"\u003eSection 24.1.3\u003c/a\u003e and \u003ca href=\"/docs/18/routine-vacuuming.html#AUTOVACUUM\" rel=\"nofollow\"\u003eSection 24.1.6\u003c/a\u003e for more\n   information.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv id=\"APP-PGRESTORE-EXAMPLES\"\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003e\n   Assume we have dumped a database called \u003ccode\u003emydb\u003c/code\u003e into a\n   custom-format dump file:\n\n\u003c/p\u003e\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_dump -Fc mydb \u0026gt; db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   To drop the database and recreate it from the dump:\n\n\u003c/p\u003e\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003edropdb mydb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_restore -C -d postgres db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   The database named in the \u003ccode\u003e-d\u003c/code\u003e switch can be any database existing\n   in the cluster; \u003cspan\u003epg_restore\u003c/span\u003e only uses it to issue the\n   \u003ccode\u003eCREATE DATABASE\u003c/code\u003e command for \u003ccode\u003emydb\u003c/code\u003e.  With\n   \u003ccode\u003e-C\u003c/code\u003e, data is always restored into the database name that appears\n   in the dump file.\n  \u003c/p\u003e\u003cp\u003e\n   To restore the dump into a new database called \u003ccode\u003enewdb\u003c/code\u003e:\n\n\u003c/p\u003e\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003ecreatedb -T template0 newdb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_restore -d newdb db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   Notice we don\u0026#39;t use \u003ccode\u003e-C\u003c/code\u003e, and instead connect directly to the\n   database to be restored into.  Also note that we clone the new database\n   from \u003ccode\u003etemplate0\u003c/code\u003e not \u003ccode\u003etemplate1\u003c/code\u003e, to ensure it is\n   initially empty.\n  \u003c/p\u003e\u003cp\u003e\n   To reorder database items, it is first necessary to dump the table of\n   contents of the archive:\n\u003c/p\u003e\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_restore -l db.dump \u0026gt; db.list\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n   The listing file consists of a header and one line for each item, e.g.:\n\u003c/p\u003e\u003cpre\u003e;\n; Archive created at Mon Sep 14 13:55:39 2009\n;     dbname: DBDEMOS\n;     TOC Entries: 81\n;     Compression: 9\n;     Dump Version: 1.10-0\n;     Format: CUSTOM\n;     Integer: 4 bytes\n;     Offset: 8 bytes\n;     Dumped from database version: 8.3.5\n;     Dumped by pg_dump version: 8.3.8\n;\n;\n; Selected TOC Entries:\n;\n3; 2615 2200 SCHEMA - public pasha\n1861; 0 0 COMMENT - SCHEMA public pasha\n1862; 0 0 ACL - public pasha\n317; 1247 17715 TYPE public composite pasha\n319; 1247 25899 DOMAIN public domain0 pasha\n\u003c/pre\u003e\u003cp\u003e\n   Semicolons start a comment, and the numbers at the start of lines refer to the\n   internal archive ID assigned to each item.\n  \u003c/p\u003e\u003cp\u003e\n   Lines in the file can be commented out, deleted, and reordered. For example:\n\u003c/p\u003e\u003cpre\u003e10; 145433 TABLE map_resolutions postgres\n;2; 145344 TABLE species postgres\n;4; 145359 TABLE nt_header postgres\n6; 145402 TABLE species_records postgres\n;8; 145416 TABLE ss_old postgres\n\u003c/pre\u003e\u003cp\u003e\n   could be used as input to \u003cspan\u003epg_restore\u003c/span\u003e and would only restore\n   items 10 and 6, in that order:\n\u003c/p\u003e\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_restore -L db.list db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cdiv id=\"id-1.9.4.19.11\"\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_dumpall\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/docs/18/app-psql.html\" title=\"psql\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","SourceRevision":"1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915","ContentHash":"7bf83a340c9eeeaec122d0b5d4c54c134799a3e5259f1546a8dcf55279cbef08","Payload":{"description":["pg_restore — restore a PostgreSQL database from an archive file created by pg_dump"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGRESTORE\"\u003e\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\u003cdiv class=\"refnamediv\"\u003e\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\u003cp\u003epg_restore — \n   restore a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an\n   archive file created by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsynopsisdiv\"\u003e\u003ch2\u003eSynopsis\u003c/h2\u003e\u003cdiv class=\"cmdsynopsis\"\u003e\u003cp id=\"id-1.9.4.19.4.1\"\u003e\u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003econnection-option\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...] [\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e]\u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DESCRIPTION\"\u003e\u003ch2\u003eDescription\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e is a utility for restoring a\n   \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an archive\n   created by \u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e in one of the non-plain-text\n   formats.  It will issue the commands necessary to reconstruct the\n   database to the state it was in at the time it was saved.  The\n   archive files also allow \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to\n   be selective about what is restored, or even to reorder the items\n   prior to being restored. The archive files are designed to be\n   portable across architectures.\n  \u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e can operate in two modes.\n   If a database name is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n   connects to that database and restores archive contents directly into\n   the database.  Otherwise, a script containing the SQL\n   commands necessary to rebuild the database is created and written\n   to a file or standard output.  This script output is equivalent to\n   the plain text output format of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\n   Some of the options controlling the output are therefore analogous to\n   \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e options.\n  \u003c/p\u003e\u003cp\u003e\n   Obviously, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore information\n   that is not present in the archive file.  For instance, if the\n   archive was made using the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edump data as\n   \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e commands\u003c/span\u003e”\u003c/span\u003e option,\n   \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will not be able to load the data\n   using \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e statements.\n  \u003c/p\u003e\u003cdiv class=\"warning\"\u003e\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\u003cp\u003e\n    Restoring a dump causes the destination to execute arbitrary code of the\n    source superusers' choice.  Partial dumps and partial restores do not limit\n    that.  If the source superusers are not trusted, the dumped SQL statements\n    must be inspected before restoring.  Non-plain-text dumps can be inspected\n    by using \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e--file\u003c/code\u003e\n    option.  Note that the client running the dump and restore need not trust\n    the source or destination superusers.\n   \u003c/p\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-OPTIONS\"\u003e\u003ch2\u003eOptions\u003c/h2\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e accepts the following command\n    line arguments.\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Specifies the location of the archive file (or directory, for a\n       directory-format archive) to be restored.\n       If not specified, the standard input is used.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-a\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the data, not the schema (data definitions) or statistics.\n        Table data, large objects, and sequence values are restored,\n        if present in the archive.\n       \u003c/p\u003e\u003cp\u003e\n        This option is similar to, but for historical reasons not identical\n        to, specifying \u003ccode class=\"option\"\u003e--section=data\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--clean\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Before restoring database objects, issue commands\n        to \u003ccode class=\"command\"\u003eDROP\u003c/code\u003e all the objects that will be restored.\n        This option is useful for overwriting an existing database.\n        If any of the objects do not exist in the destination database,\n        ignorable error messages will be reported,\n        unless \u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e is also specified.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Create the database before restoring into it.\n        If \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also specified, drop and\n        recreate the target database before connecting to it.\n       \u003c/p\u003e\u003cp\u003e\n        With \u003ccode class=\"option\"\u003e--create\u003c/code\u003e, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n        also restores the database's comment if any, and any configuration\n        variable settings that are specific to this database, that is,\n        any \u003ccode class=\"command\"\u003eALTER DATABASE ... SET ...\u003c/code\u003e\n        and \u003ccode class=\"command\"\u003eALTER ROLE ... IN DATABASE ... SET ...\u003c/code\u003e\n        commands that mention this database.\n        Access privileges for the database itself are also restored,\n        unless \u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e is specified.\n       \u003c/p\u003e\u003cp\u003e\n        When this option is used, the database named with \u003ccode class=\"option\"\u003e-d\u003c/code\u003e\n        is used only to issue the initial \u003ccode class=\"command\"\u003eDROP DATABASE\u003c/code\u003e and\n        \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e commands.  All data is restored into the\n        database name that appears in the archive.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Connect to database \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e and restore directly\n        into the database.  The \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can\n        be a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e.\n        If so, connection string parameters will override any conflicting\n        command line options.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Exit if an error is encountered while sending SQL commands to\n        the database. The default is to continue and to display a count of\n        errors at the end of the restoration.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-f \u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--file=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify output file for generated script, or for the listing\n        when used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e. Use \u003ccode class=\"literal\"\u003e-\u003c/code\u003e\n        for \u003cspan class=\"systemitem\"\u003estdout\u003c/span\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F \u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--format=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify format of the archive.  It is not necessary to specify\n        the format, since \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will\n        determine the format automatically. If specified, it can be\n        one of the following:\n\n       \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ec\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ecustom\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is in the custom format of\n           \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ed\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003edirectory\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is a directory archive.\n          \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etar\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n           The archive is a \u003ccode class=\"command\"\u003etar\u003c/code\u003e archive.\n          \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-I \u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--index=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eindex\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore definition of named index only.  Multiple indexes\n        may be specified with multiple \u003ccode class=\"option\"\u003e-I\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-j \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--jobs=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Run the most time-consuming steps\n        of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e — those that load data,\n        create indexes, or create constraints — concurrently, using up\n        to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e\n        concurrent sessions.  This option can dramatically reduce the time\n        to restore a large database to a server running on a\n        multiprocessor machine.  This option is ignored when emitting a script\n        rather than connecting directly to a database server.\n       \u003c/p\u003e\u003cp\u003e\n        Each job is one process or one thread, depending on the\n        operating system, and uses a separate connection to the\n        server.\n       \u003c/p\u003e\u003cp\u003e\n        The optimal value for this option depends on the hardware\n        setup of the server, of the client, and of the network.\n        Factors include the number of CPU cores and the disk setup.  A\n        good place to start is the number of CPU cores on the server,\n        but values larger than that can also lead to faster restore\n        times in many cases.  Of course, values that are too high will\n        lead to decreased performance because of thrashing.\n       \u003c/p\u003e\u003cp\u003e\n        Only the custom and directory archive formats are supported\n        with this option.\n        The input must be a regular file or directory (not, for example, a\n        pipe or standard input).  Also, multiple\n        jobs cannot be used together with the\n        option \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--list\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        List the table of contents of the archive. The output of this operation\n        can be used as input to the \u003ccode class=\"option\"\u003e-L\u003c/code\u003e option.  Note that\n        if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are\n        used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e, they will restrict the items listed.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-L \u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-list=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only those archive elements that are listed in \u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e, and restore them in the\n        order they appear in the file.  Note that\n        if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are\n        used with \u003ccode class=\"option\"\u003e-L\u003c/code\u003e, they will further restrict the items restored.\n       \u003c/p\u003e\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e is normally created by\n        editing the output of a previous \u003ccode class=\"option\"\u003e-l\u003c/code\u003e operation.\n        Lines can be moved or removed, and can also\n        be commented out by placing a semicolon (\u003ccode class=\"literal\"\u003e;\u003c/code\u003e) at the\n        start of the line.  See below for examples.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--schema=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only objects that are in the named schema.  Multiple schemas\n        may be specified with multiple \u003ccode class=\"option\"\u003e-n\u003c/code\u003e switches.  This can be\n        combined with the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e option to restore just a\n        specific table.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N \u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--exclude-schema=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eschema\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not restore objects that are in the named schema.  Multiple schemas\n        to be excluded may be specified with multiple \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switches.\n       \u003c/p\u003e\u003cp\u003e\n        When both \u003ccode class=\"option\"\u003e-n\u003c/code\u003e and \u003ccode class=\"option\"\u003e-N\u003c/code\u003e are given for the same\n        schema name, the \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switch wins and the schema is excluded.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-O\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-owner\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to set\n        ownership of objects to match the original database.\n        By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e issues\n        \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e or\n        \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e\n        statements to set ownership of created schema elements.\n        These statements will fail unless the initial connection to the\n        database is made by a superuser\n        (or the same user that owns all of the objects in the script).\n        With \u003ccode class=\"option\"\u003e-O\u003c/code\u003e, any user name can be used for the\n        initial connection, and this user will own all the created objects.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P \u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--function=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efunction-name(argtype [, ...])\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore the named function only.  Be careful to spell the function\n        name and arguments exactly as they appear in the dump file's table\n        of contents.  Multiple functions may be specified with multiple\n        \u003ccode class=\"option\"\u003e-P\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-reconnect\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is obsolete but still accepted for backwards\n        compatibility.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--schema-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the schema (data definitions), not data,\n        to the extent that schema entries are present in the archive.\n       \u003c/p\u003e\u003cp\u003e\n        This option cannot be used with \u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e\n        or \u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e.\n        It is similar to, but for historical reasons not identical to,\n        specifying\n        \u003ccode class=\"option\"\u003e--section=pre-data --section=post-data --no-statistics\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n        (Do not confuse this with the \u003ccode class=\"option\"\u003e--schema\u003c/code\u003e option, which\n        uses the word \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eschema\u003c/span\u003e”\u003c/span\u003e in a different meaning.)\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--superuser=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify the superuser user name to use when disabling triggers.\n        This is relevant only if \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t \u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--table=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etable\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore definition and/or data of only the named table.\n        For this purpose, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etable\u003c/span\u003e”\u003c/span\u003e includes views, materialized views,\n        sequences, and foreign tables.  Multiple tables\n        can be selected by writing multiple \u003ccode class=\"option\"\u003e-t\u003c/code\u003e switches.\n        This option can be combined with the \u003ccode class=\"option\"\u003e-n\u003c/code\u003e option to\n        specify table(s) in a particular schema.\n       \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         When \u003ccode class=\"option\"\u003e-t\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n         makes no attempt to restore any other database objects that the\n         selected table(s) might depend upon.  Therefore, there is no\n         guarantee that a specific-table restore into a clean database will\n         succeed.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         This flag does not behave identically to the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e\n         flag of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.  There is not currently\n         any provision for wild-card matching in \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e,\n         nor can you include a schema name within its \u003ccode class=\"option\"\u003e-t\u003c/code\u003e.\n         And, while \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e\n         flag will also dump subsidiary objects (such as indexes) of the\n         selected table(s),\n         \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e\n         flag does not include such subsidiary objects.\n        \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         In versions prior to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, this flag\n         matched only tables, not any other type of relation.\n        \u003c/p\u003e\u003c/div\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--trigger=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etrigger\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore named trigger only.  Multiple triggers may be specified with\n        multiple \u003ccode class=\"option\"\u003e-T\u003c/code\u003e switches.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies verbose mode.  This will cause\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to output detailed object\n        comments and start/stop times to the output file, and progress\n        messages to standard error.\n        Repeating the option causes additional debug-level messages\n        to appear on standard error.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Print the \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e version and exit.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-x\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-privileges\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Prevent restoration of access privileges (grant/revoke commands).\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-1\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Execute the restore as a single transaction (that is, wrap the\n        emitted commands in \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e).  This\n        ensures that either all the commands complete successfully, or no\n        changes are applied. This option implies\n        \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is relevant only when performing a restore without schema.\n        It instructs \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to execute commands\n        to temporarily disable triggers on the target tables while\n        the data is restored.  Use this if you have referential\n        integrity checks or other triggers on the tables that you\n        do not want to invoke during data restore.\n       \u003c/p\u003e\u003cp\u003e\n        Presently, the commands emitted for\n        \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e must be done as superuser.  So you\n        should also specify a superuser name with \u003ccode class=\"option\"\u003e-S\u003c/code\u003e or,\n        preferably, run \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e as a\n        \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e superuser.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--enable-row-security\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        This option is relevant only when restoring the contents of a table\n        which has row security.  By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will set\n        \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e to off, to ensure\n        that all data is restored in to the table.  If the user does not have\n        sufficient privileges to bypass row security, then an error is thrown.\n        This parameter instructs \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to set\n        \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e to on instead, allowing the user to attempt to restore\n        the contents of the table with row security enabled.  This might still\n        fail if the user does not have the right to insert the rows from the\n        dump into the table.\n       \u003c/p\u003e\u003cp\u003e\n        Note that this option currently also requires the dump be in \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e\n        format, as \u003ccode class=\"command\"\u003eCOPY FROM\u003c/code\u003e does not support row security.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--filter=\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specify a filename from which to read patterns for objects excluded\n        or included from restore. The patterns are interpreted according to the\n        same rules as\n        \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e for including objects in schemas,\n        \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e for excluding objects in schemas,\n        \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e for restoring named functions,\n        \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e for restoring named indexes,\n        \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e for restoring named tables\n        or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e for restoring triggers.\n        To read from \u003ccode class=\"literal\"\u003eSTDIN\u003c/code\u003e, use \u003ccode class=\"filename\"\u003e-\u003c/code\u003e as the\n        filename.  The \u003ccode class=\"option\"\u003e--filter\u003c/code\u003e option can be specified in\n        conjunction with the above listed options for including or excluding\n        objects, and can also be specified more than once for multiple filter\n        files.\n       \u003c/p\u003e\u003cp\u003e\n        The file lists one database pattern per row, with the following format:\n\u003c/p\u003e\u003cpre class=\"synopsis\"\u003e{ include | exclude } { function | index | schema | table | trigger } \u003cem class=\"replaceable\"\u003e\u003ccode\u003ePATTERN\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        The first keyword specifies whether the objects matched by the pattern\n        are to be included or excluded. The second keyword specifies the type\n        of object to be filtered using the pattern:\n        \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003efunction\u003c/code\u003e: functions, works like the\n           \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003eindex\u003c/code\u003e: indexes, works like the\n           \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003eschema\u003c/code\u003e: schemas, works like the\n           \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e and\n           \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e options.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003etable\u003c/code\u003e: tables, works like the\n           \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n\u003ccode class=\"literal\"\u003etrigger\u003c/code\u003e: triggers, works like the\n           \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e option. This keyword\n           can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\n          \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n        Lines starting with \u003ccode class=\"literal\"\u003e#\u003c/code\u003e are considered comments and\n        ignored. Comments can be placed after an object pattern row as well.\n        Blank lines are also ignored. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003ePatterns\u003c/a\u003e\n        for how to perform quoting in patterns.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Use \u003ccode class=\"literal\"\u003eDROP ... IF EXISTS\u003c/code\u003e commands to drop objects\n        in \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e mode.  This suppresses \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edoes not\n        exist\u003c/span\u003e”\u003c/span\u003e errors that might otherwise be reported.  This\n        option is not valid unless \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also\n        specified.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-comments\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore comments, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore data, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-for-failed-tables\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        By default, table data is restored even if the creation command\n        for the table failed (e.g., because it already exists).\n        With this option, data for such a table is skipped.\n        This behavior is useful if the target database already\n        contains the desired table contents.  For example,\n        auxiliary tables for \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extensions\n        such as \u003cspan class=\"productname\"\u003ePostGIS\u003c/span\u003e might already be loaded in\n        the target database; specifying this option prevents duplicate\n        or obsolete data from being loaded into them.\n       \u003c/p\u003e\u003cp\u003e\n        This option is effective only when restoring directly into a\n        database, not when producing SQL script output.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-policies\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore row security policies, even if\n        the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-publications\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore publications, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-schema\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore schema (data definitions), even if\n        the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-security-labels\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore security labels,\n        even if the archive contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore statistics, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-subscriptions\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to restore subscriptions, even if the archive\n        contains them.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-table-access-method\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to select table access methods.\n        With this option, all objects will be created with whichever\n        table access method is the default during restore.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-tablespaces\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Do not output commands to select tablespaces.\n        With this option, all objects will be created in whichever\n        tablespace is the default during restore.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--restrict-key=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erestrict_key\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Use the provided string as the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e\n\u003ccode class=\"command\"\u003e\\restrict\u003c/code\u003e key in the dump output.  This can only be\n        specified for SQL script output, i.e., when the \u003ccode class=\"option\"\u003e--file\u003c/code\u003e\n        option is used.  If no restrict key is specified,\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will generate a random one as\n        needed.  Keys may contain only alphanumeric characters.\n       \u003c/p\u003e\u003cp\u003e\n        This option is primarily intended for testing purposes and other\n        scenarios that require repeatable output (e.g., comparing dump files).\n        It is not recommended for general use, as a malicious server with\n        advance knowledge of the key may be able to inject arbitrary code that\n        will be executed on the machine that runs\n        \u003cspan class=\"application\"\u003epsql\u003c/span\u003e with the dump output.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--section=\u003cem class=\"replaceable\"\u003e\u003ccode\u003esectionname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n          Only restore the named section. The section name can be\n          \u003ccode class=\"option\"\u003epre-data\u003c/code\u003e, \u003ccode class=\"option\"\u003edata\u003c/code\u003e, or \u003ccode class=\"option\"\u003epost-data\u003c/code\u003e.\n          This option can be specified more than once to select multiple\n          sections. The default is to restore all sections.\n         \u003c/p\u003e\u003cp\u003e\n          The data section contains actual table data as well as large-object\n          definitions.\n          Post-data items consist of definitions of indexes, triggers, rules\n          and constraints other than validated check constraints.\n          Pre-data items consist of all other data definition items.\n         \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Output commands to restore statistics, if the archive contains them.\n        This is the default.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Restore only the statistics, not schema (data definitions) or data.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--strict-names\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Require that each schema\n        (\u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e) and table\n        (\u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e) qualifier match at\n        least one schema/table in the file to be restored.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--transaction-size=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Execute the restore as a series of transactions, each processing\n        up to \u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e database\n        objects.  This option implies \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\n       \u003c/p\u003e\u003cp\u003e\n\u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e offers an intermediate choice\n        between the default behavior (one transaction per SQL command)\n        and \u003ccode class=\"option\"\u003e-1\u003c/code\u003e/\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e\n        (one transaction for all restored objects).\n        While \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e has the least\n        overhead, it may be impractical for large databases because the\n        transaction will take a lock on each restored object, possibly\n        exhausting the server's lock table space.\n        Using \u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e with a size of a few\n        thousand objects offers nearly the same performance benefits while\n        capping the amount of lock table space needed.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-set-session-authorization\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Output SQL-standard \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e commands\n        instead of \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e commands to determine object\n        ownership.  This makes the dump more standards-compatible, but\n        depending on the history of the objects in the dump, might not restore\n        properly.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n       Show help about \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e command line\n       arguments, and exit.\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e also accepts\n    the following command line arguments for connection parameters:\n\n    \u003c/p\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies the host name of the machine on which the server is\n        running.  If the value begins with a slash, it is used as the\n        directory for the Unix domain socket. The default is taken\n        from the \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set,\n        else a Unix domain socket connection is attempted.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies the TCP port or local Unix domain socket file\n        extension on which the server is listening for connections.\n        Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if\n        set, or a compiled-in default.\n        \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        User name to connect as.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Never issue a password prompt.  If the server requires\n        password authentication and a password is not available by\n        other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the\n        connection attempt will fail.  This option can be useful in\n        batch jobs and scripts where no user is present to enter a\n        password.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Force \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to prompt for a\n        password before connecting to a database.\n       \u003c/p\u003e\u003cp\u003e\n        This option is never essential, since\n        \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will automatically prompt\n        for a password if the server demands password authentication.\n        However, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will waste a\n        connection attempt finding out that the server wants a password.\n        In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra\n        connection attempt.\n       \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--role=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n        Specifies a role name to be used to perform the restore.\n        This option causes \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to issue a\n        \u003ccode class=\"command\"\u003eSET ROLE\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e\n        command after connecting to the database. It is useful when the\n        authenticated user (specified by \u003ccode class=\"option\"\u003e-U\u003c/code\u003e) lacks privileges\n        needed by \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, but can switch to a role with\n        the required rights.  Some installations have a policy against\n        logging in directly as a superuser, and use of this option allows\n        restores to be performed without violating the policy.\n       \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.7\"\u003e\u003ch2\u003eEnvironment\u003c/h2\u003e\u003cdiv class=\"variablelist\"\u003e\u003cdl class=\"variablelist\"\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGOPTIONS\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePGUSER\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      Default connection parameters\n     \u003c/p\u003e\u003c/dd\u003e\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\u003cdd\u003e\u003cp\u003e\n      Specifies whether to use color in diagnostic messages. Possible values\n      are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and\n      \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\n     \u003c/p\u003e\u003c/dd\u003e\u003c/dl\u003e\u003c/div\u003e\u003cp\u003e\n   This utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities,\n   also uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e\n   (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).  However, it does not read\n   \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e when a database name is not supplied.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DIAGNOSTICS\"\u003e\u003ch2\u003eDiagnostics\u003c/h2\u003e\u003cp\u003e\n   When a direct database connection is specified using the\n   \u003ccode class=\"option\"\u003e-d\u003c/code\u003e option, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\n   internally executes SQL statements. If you have\n   problems running \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, make sure\n   you are able to select information from the database using, for\n   example, \u003ca class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e.  Also, any default connection\n   settings and environment variables used by the\n   \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e front-end library will apply.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-NOTES\"\u003e\u003ch2\u003eNotes\u003c/h2\u003e\u003cp\u003e\n   If your installation has any local additions to the\n   \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e database, be careful to load the output of\n   \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e into a truly empty database;\n   otherwise you are likely to get errors due to duplicate definitions\n   of the added objects.  To make an empty database without any local\n   additions, copy from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, for example:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003eCREATE DATABASE foo WITH TEMPLATE template0;\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   The limitations of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e are detailed below.\n\n   \u003c/p\u003e\u003cdiv class=\"itemizedlist\"\u003e\u003cul class=\"itemizedlist\"\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\n      When restoring data to a pre-existing table and the option\n      \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used,\n      \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e emits commands\n      to disable triggers on user tables before inserting the data, then emits commands to\n      re-enable them after the data has been inserted.  If the restore is stopped in the\n      middle, the system catalogs might be left in the wrong state.\n     \u003c/p\u003e\u003c/li\u003e\u003cli class=\"listitem\"\u003e\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore large objects\n      selectively;  for instance, only those for a specific table.  If\n      an archive contains large objects, then all large objects will be\n      restored, or none of them if they are excluded via \u003ccode class=\"option\"\u003e-L\u003c/code\u003e,\n      \u003ccode class=\"option\"\u003e-t\u003c/code\u003e, or other options.\n     \u003c/p\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   See also the \u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e documentation for details on\n   limitations of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\n  \u003c/p\u003e\u003cp\u003e\n   By default, \u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e will restore optimizer statistics\n   if included in the dump file.  If not all statistics were restored, it may\n   be useful to run \u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e on each restored table so the\n   optimizer has useful statistics; see \u003ca class=\"xref\" href=\"/docs/18/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3. Updating Planner Statistics\"\u003eSection 24.1.3\u003c/a\u003e and \u003ca class=\"xref\" href=\"/docs/18/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6. The Autovacuum Daemon\"\u003eSection 24.1.6\u003c/a\u003e for more\n   information.\n  \u003c/p\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-EXAMPLES\"\u003e\u003ch2\u003eExamples\u003c/h2\u003e\u003cp\u003e\n   Assume we have dumped a database called \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e into a\n   custom-format dump file:\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_dump -Fc mydb \u0026gt; db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\u003c/p\u003e\u003cp\u003e\n   To drop the database and recreate it from the dump:\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003edropdb mydb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -C -d postgres db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   The database named in the \u003ccode class=\"option\"\u003e-d\u003c/code\u003e switch can be any database existing\n   in the cluster; \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e only uses it to issue the\n   \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e command for \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e.  With\n   \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, data is always restored into the database name that appears\n   in the dump file.\n  \u003c/p\u003e\u003cp\u003e\n   To restore the dump into a new database called \u003ccode class=\"literal\"\u003enewdb\u003c/code\u003e:\n\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003ecreatedb -T template0 newdb\u003c/code\u003e\u003c/strong\u003e\n\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -d newdb db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n\n   Notice we don't use \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, and instead connect directly to the\n   database to be restored into.  Also note that we clone the new database\n   from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, to ensure it is\n   initially empty.\n  \u003c/p\u003e\u003cp\u003e\n   To reorder database items, it is first necessary to dump the table of\n   contents of the archive:\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -l db.dump \u0026gt; db.list\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003cp\u003e\n   The listing file consists of a header and one line for each item, e.g.:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e;\n; Archive created at Mon Sep 14 13:55:39 2009\n;     dbname: DBDEMOS\n;     TOC Entries: 81\n;     Compression: 9\n;     Dump Version: 1.10-0\n;     Format: CUSTOM\n;     Integer: 4 bytes\n;     Offset: 8 bytes\n;     Dumped from database version: 8.3.5\n;     Dumped by pg_dump version: 8.3.8\n;\n;\n; Selected TOC Entries:\n;\n3; 2615 2200 SCHEMA - public pasha\n1861; 0 0 COMMENT - SCHEMA public pasha\n1862; 0 0 ACL - public pasha\n317; 1247 17715 TYPE public composite pasha\n319; 1247 25899 DOMAIN public domain0 pasha\n\u003c/pre\u003e\u003cp\u003e\n   Semicolons start a comment, and the numbers at the start of lines refer to the\n   internal archive ID assigned to each item.\n  \u003c/p\u003e\u003cp\u003e\n   Lines in the file can be commented out, deleted, and reordered. For example:\n\u003c/p\u003e\u003cpre class=\"programlisting\"\u003e10; 145433 TABLE map_resolutions postgres\n;2; 145344 TABLE species postgres\n;4; 145359 TABLE nt_header postgres\n6; 145402 TABLE species_records postgres\n;8; 145416 TABLE ss_old postgres\n\u003c/pre\u003e\u003cp\u003e\n   could be used as input to \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e and would only restore\n   items 10 and 6, in that order:\n\u003c/p\u003e\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_restore -L db.list db.dump\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.11\"\u003e\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dumpall\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epsql\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","related":[{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-a --data-only","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive."},{"signature":{"text":"-c --clean","url":"/docs/18/app-pgrestore.html"},"summary":"Before restoring database objects, issue commands to DROP all the objects that will be restored. This option is useful for overwriting an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported, unless --if-exists is also specified."},{"signature":{"text":"-C --create","url":"/docs/18/app-pgrestore.html"},"summary":"Create the database before restoring into it. If --clean is also specified, drop and recreate the target database before connecting to it."},{"signature":{"text":"-d dbname --dbname= dbname","url":"/docs/18/app-pgrestore.html"},"summary":"Connect to database dbname and restore directly into the database. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."},{"signature":{"text":"-e --exit-on-error","url":"/docs/18/app-pgrestore.html"},"summary":"Exit if an error is encountered while sending SQL commands to the database. The default is to continue and to display a count of errors at the end of the restoration."},{"signature":{"text":"-f filename --file= filename","url":"/docs/18/app-pgrestore.html"},"summary":"Specify output file for generated script, or for the listing when used with -l . Use - for stdout ."},{"signature":{"text":"-F format --format= format","url":"/docs/18/app-pgrestore.html"},"summary":"Specify format of the archive. It is not necessary to specify the format, since pg_restore will determine the format automatically. If specified, it can be one of the following:"},{"signature":{"text":"-I index --index= index","url":"/docs/18/app-pgrestore.html"},"summary":"Restore definition of named index only. Multiple indexes may be specified with multiple -I switches."},{"signature":{"text":"-j number-of-jobs --jobs= number-of-jobs","url":"/docs/18/app-pgrestore.html"},"summary":"Run the most time-consuming steps of pg_restore — those that load data, create indexes, or create constraints — concurrently, using up to number-of-jobs concurrent sessions. This option can dramatically reduce the time to restore a large database to a server running on a multiprocessor machine. This option is ignored when emitting a script rather than connecting directly to a database server."},{"signature":{"text":"-l --list","url":"/docs/18/app-pgrestore.html"},"summary":"List the table of contents of the archive. The output of this operation can be used as input to the -L option. Note that if filtering switches such as -n or -t are used with -l , they will restrict the items listed."},{"signature":{"text":"-L list-file --use-list= list-file","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only those archive elements that are listed in list-file , and restore them in the order they appear in the file. Note that if filtering switches such as -n or -t are used with -L , they will further restrict the items restored."},{"signature":{"text":"-n schema --schema= schema","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only objects that are in the named schema. Multiple schemas may be specified with multiple -n switches. This can be combined with the -t option to restore just a specific table."},{"signature":{"text":"-N schema --exclude-schema= schema","url":"/docs/18/app-pgrestore.html"},"summary":"Do not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple -N switches."},{"signature":{"text":"-O --no-owner","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O , any user name can be used for the initial connection, and this user will own all the created objects."},{"signature":{"text":"-P function-name(argtype [, ...]) --function= function-name(argtype [, ...])","url":"/docs/18/app-pgrestore.html"},"summary":"Restore the named function only. Be careful to spell the function name and arguments exactly as they appear in the dump file's table of contents. Multiple functions may be specified with multiple -P switches."},{"signature":{"text":"-R --no-reconnect","url":"/docs/18/app-pgrestore.html"},"summary":"This option is obsolete but still accepted for backwards compatibility."},{"signature":{"text":"-s --schema-only","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only the schema (data definitions), not data, to the extent that schema entries are present in the archive."},{"signature":{"text":"-S username --superuser= username","url":"/docs/18/app-pgrestore.html"},"summary":"Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used."},{"signature":{"text":"-t table --table= table","url":"/docs/18/app-pgrestore.html"},"summary":"Restore definition and/or data of only the named table. For this purpose, “ table ” includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. This option can be combined with the -n option to specify table(s) in a particular schema."},{"signature":{"text":"-T trigger --trigger= trigger","url":"/docs/18/app-pgrestore.html"},"summary":"Restore named trigger only. Multiple triggers may be specified with multiple -T switches."},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgrestore.html"},"summary":"Specifies verbose mode. This will cause pg_restore to output detailed object comments and start/stop times to the output file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."},{"signature":{"text":"-V --version","url":"/docs/18/app-pgrestore.html"},"summary":"Print the pg_restore version and exit."},{"signature":{"text":"-x --no-privileges --no-acl","url":"/docs/18/app-pgrestore.html"},"summary":"Prevent restoration of access privileges (grant/revoke commands)."},{"signature":{"text":"-1 --single-transaction","url":"/docs/18/app-pgrestore.html"},"summary":"Execute the restore as a single transaction (that is, wrap the emitted commands in BEGIN / COMMIT ). This ensures that either all the commands complete successfully, or no changes are applied. This option implies --exit-on-error ."},{"signature":{"text":"--disable-triggers","url":"/docs/18/app-pgrestore.html"},"summary":"This option is relevant only when performing a restore without schema. It instructs pg_restore to execute commands to temporarily disable triggers on the target tables while the data is restored. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data restore."},{"signature":{"text":"--enable-row-security","url":"/docs/18/app-pgrestore.html"},"summary":"This option is relevant only when restoring the contents of a table which has row security. By default, pg_restore will set row_security to off, to ensure that all data is restored in to the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_restore to set row_security to on instead, allowing the user to attempt to restore the contents of the table with row security enabled. This might still fail if the user does not have the right to insert the rows from the dump into the table."},{"signature":{"text":"--filter= filename","url":"/docs/18/app-pgrestore.html"},"summary":"Specify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as -n / --schema for including objects in schemas, -N / --exclude-schema for excluding objects in schemas, -P / --function for restoring named functions, -I / --index for restoring named indexes, -t / --table for restoring named tables or -T / --trigger for restoring triggers. To read from STDIN , use - as the filename. The --filter option can be specified in conjunction with the above listed options for including or excluding objects, and can also be specified more than once for multiple filter files."},{"signature":{"text":"--if-exists","url":"/docs/18/app-pgrestore.html"},"summary":"Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses “ does not exist ” errors that might otherwise be reported. This option is not valid unless --clean is also specified."},{"signature":{"text":"--no-comments","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore comments, even if the archive contains them."},{"signature":{"text":"--no-data","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore data, even if the archive contains them."},{"signature":{"text":"--no-data-for-failed-tables","url":"/docs/18/app-pgrestore.html"},"summary":"By default, table data is restored even if the creation command for the table failed (e.g., because it already exists). With this option, data for such a table is skipped. This behavior is useful if the target database already contains the desired table contents. For example, auxiliary tables for PostgreSQL extensions such as PostGIS might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them."},{"signature":{"text":"--no-policies","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore row security policies, even if the archive contains them."},{"signature":{"text":"--no-publications","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore publications, even if the archive contains them."},{"signature":{"text":"--no-schema","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore schema (data definitions), even if the archive contains them."},{"signature":{"text":"--no-security-labels","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore security labels, even if the archive contains them."},{"signature":{"text":"--no-statistics","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore statistics, even if the archive contains them."},{"signature":{"text":"--no-subscriptions","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to restore subscriptions, even if the archive contains them."},{"signature":{"text":"--no-table-access-method","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to select table access methods. With this option, all objects will be created with whichever table access method is the default during restore."},{"signature":{"text":"--no-tablespaces","url":"/docs/18/app-pgrestore.html"},"summary":"Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore."},{"signature":{"text":"--restrict-key= restrict_key","url":"/docs/18/app-pgrestore.html"},"summary":"Use the provided string as the psql \\restrict key in the dump output. This can only be specified for SQL script output, i.e., when the --file option is used. If no restrict key is specified, pg_restore will generate a random one as needed. Keys may contain only alphanumeric characters."},{"signature":{"text":"--section= sectionname","url":"/docs/18/app-pgrestore.html"},"summary":"Only restore the named section. The section name can be pre-data , data , or post-data . This option can be specified more than once to select multiple sections. The default is to restore all sections."},{"signature":{"text":"--statistics","url":"/docs/18/app-pgrestore.html"},"summary":"Output commands to restore statistics, if the archive contains them. This is the default."},{"signature":{"text":"--statistics-only","url":"/docs/18/app-pgrestore.html"},"summary":"Restore only the statistics, not schema (data definitions) or data."},{"signature":{"text":"--strict-names","url":"/docs/18/app-pgrestore.html"},"summary":"Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the file to be restored."},{"signature":{"text":"--transaction-size= N","url":"/docs/18/app-pgrestore.html"},"summary":"Execute the restore as a series of transactions, each processing up to N database objects. This option implies --exit-on-error ."},{"signature":{"text":"--use-set-session-authorization","url":"/docs/18/app-pgrestore.html"},"summary":"Output SQL-standard SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to determine object ownership. This makes the dump more standards-compatible, but depending on the history of the objects in the dump, might not restore properly."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgrestore.html"},"summary":"Show help about pg_restore command line arguments, and exit."},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgrestore.html"},"summary":"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 PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgrestore.html"},"summary":"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."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgrestore.html"},"summary":"User name to connect as."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgrestore.html"},"summary":"Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-pgrestore.html"},"summary":"Force pg_restore to prompt for a password before connecting to a database."},{"signature":{"text":"--role= rolename","url":"/docs/18/app-pgrestore.html"},"summary":"Specifies a role name to be used to perform the restore. This option causes pg_restore to issue a SET ROLE rolename command after connecting to the database. It is useful when the authenticated user (specified by -U ) lacks privileges needed by pg_restore , but can switch to a role with the required rights. Some installations have a policy against logging in directly as a superuser, and use of this option allows restores to be performed without violating the policy."}],"title":"Documented options"},{"columns":[{"key":"name","label":"Variable"},{"key":"description","label":"Meaning"}],"key":"environment","rows":[{"description":"Default connection parameters","name":"PGHOST PGOPTIONS PGPORT PGUSER"},{"description":"Specifies whether to use color in diagnostic messages. Possible values are always , auto and never .","name":"PG_COLOR"}],"title":"Environment variables"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
