{"Entry":{"collection":"tool","key":"pg-restore","name":"pg_restore","aliases":["pg_restore"],"metadata":{"aliases":["pg_restore"],"category":"Client applications","content_hash":"1ee014b8132249ec873b1c199a0ef3c7d86e5a9b14605318cd42aabcefe80257","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":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","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 / --indexes 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"],"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.6"},{"label":"Reference inventory","value":"Client applications"},{"label":"Option definition groups","value":"53"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGRESTORE\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_restore — restore a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an archive file created by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\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\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DESCRIPTION\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e is a utility for restoring a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an archive 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 formats. It will issue the commands necessary to reconstruct the database to the state it was in at the time it was saved. The archive files also allow \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to be selective about what is restored, or even to reorder the items prior to being restored. The archive files are designed to be portable across architectures.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e can operate in two modes. If a database name is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e connects to that database and restores archive contents directly into the database. Otherwise, a script containing the SQL commands necessary to rebuild the database is created and written to a file or standard output. This script output is equivalent to the plain text output format of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e. Some of the options controlling the output are therefore analogous to \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e options.\u003c/p\u003e\n\u003cp\u003eObviously, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore information that is not present in the archive file. For instance, if the archive was made using the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edump data as \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e commands\u003c/span\u003e”\u003c/span\u003e option, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will not be able to load the data using \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e statements.\u003c/p\u003e\n\u003cdiv class=\"warning\"\u003e\n\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\n\u003cp\u003eRestoring a dump causes the destination to execute arbitrary code of the source superusers' choice. Partial dumps and partial restores do not limit that. If the source superusers are not trusted, the dumped SQL statements must be inspected before restoring. Non-plain-text dumps can be inspected by using \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e--file\u003c/code\u003e option. Note that the client running the dump and restore need not trust the source or destination superusers.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-OPTIONS\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e accepts the following command line arguments.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the archive file (or directory, for a directory-format archive) to be restored. If not specified, the standard input is used.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive.\u003c/p\u003e\n\u003cp\u003eThis option is similar to, but for historical reasons not identical to, specifying \u003ccode class=\"option\"\u003e--section=data\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eBefore restoring database objects, issue commands to \u003ccode class=\"command\"\u003eDROP\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e is also specified.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eCreate the database before restoring into it. If \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also specified, drop and recreate the target database before connecting to it.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode class=\"option\"\u003e--create\u003c/code\u003e, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e also restores the database's comment if any, and any configuration variable settings that are specific to this database, that is, any \u003ccode class=\"command\"\u003eALTER DATABASE ... SET ...\u003c/code\u003e and \u003ccode class=\"command\"\u003eALTER ROLE ... IN DATABASE ... SET ...\u003c/code\u003e commands that mention this database. Access privileges for the database itself are also restored, unless \u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e is specified.\u003c/p\u003e\n\u003cp\u003eWhen this option is used, the database named with \u003ccode class=\"option\"\u003e-d\u003c/code\u003e is used only to issue the initial \u003ccode class=\"command\"\u003eDROP DATABASE\u003c/code\u003e and \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e commands. All data is restored into the database name that appears in the archive.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eConnect to database \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e and restore directly into the database. The \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can be a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e. If so, connection string parameters will override any conflicting command line options.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExit 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify output file for generated script, or for the listing when used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e. Use \u003ccode class=\"literal\"\u003e-\u003c/code\u003e for \u003cspan class=\"systemitem\"\u003estdout\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify format of the archive. It is not necessary to specify the format, since \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will determine the format automatically. If specified, it can be one of the following:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is in the custom format of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is a directory archive.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is a \u003ccode class=\"command\"\u003etar\u003c/code\u003e archive.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore definition of named index only. Multiple indexes may be specified with multiple \u003ccode class=\"option\"\u003e-I\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRun the most time-consuming steps of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e — those that load data, create indexes, or create constraints — concurrently, using up to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e 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.\u003c/p\u003e\n\u003cp\u003eEach job is one process or one thread, depending on the operating system, and uses a separate connection to the server.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003cp\u003eOnly 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 \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eList the table of contents of the archive. The output of this operation can be used as input to the \u003ccode class=\"option\"\u003e-L\u003c/code\u003e option. Note that if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e, they will restrict the items listed.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore 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 order they appear in the file. Note that if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are used with \u003ccode class=\"option\"\u003e-L\u003c/code\u003e, they will further restrict the items restored.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e is normally created by editing the output of a previous \u003ccode class=\"option\"\u003e-l\u003c/code\u003e operation. Lines can be moved or removed, and can also be commented out by placing a semicolon (\u003ccode class=\"literal\"\u003e;\u003c/code\u003e) at the start of the line. See below for examples.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only objects that are in the named schema. Multiple schemas may be specified with multiple \u003ccode class=\"option\"\u003e-n\u003c/code\u003e switches. This can be combined with the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e option to restore just a specific table.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDo not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switches.\u003c/p\u003e\n\u003cp\u003eWhen both \u003ccode class=\"option\"\u003e-n\u003c/code\u003e and \u003ccode class=\"option\"\u003e-N\u003c/code\u003e are given for the same schema name, the \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switch wins and the schema is excluded.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to set ownership of objects to match the original database. By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e issues \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e or \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e-O\u003c/code\u003e, any user name can be used for the initial connection, and this user will own all the created objects.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore 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 \u003ccode class=\"option\"\u003e-P\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThis option is obsolete but still accepted for backwards compatibility.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only the schema (data definitions), not data, to the extent that schema entries are present in the archive.\u003c/p\u003e\n\u003cp\u003eThis option cannot be used with \u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e or \u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e. It is similar to, but for historical reasons not identical to, specifying \u003ccode class=\"option\"\u003e--section=pre-data --section=post-data --no-statistics\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e(Do not confuse this with the \u003ccode class=\"option\"\u003e--schema\u003c/code\u003e option, which uses the word \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eschema\u003c/span\u003e”\u003c/span\u003e in a different meaning.)\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify the superuser user name to use when disabling triggers. This is relevant only if \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore definition and/or data of only the named table. For this purpose, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etable\u003c/span\u003e”\u003c/span\u003e includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple \u003ccode class=\"option\"\u003e-t\u003c/code\u003e switches. This option can be combined with the \u003ccode class=\"option\"\u003e-n\u003c/code\u003e option to specify table(s) in a particular schema.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhen \u003ccode class=\"option\"\u003e-t\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis flag does not behave identically to the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e flag of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e. There is not currently any provision for wild-card matching in \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, nor can you include a schema name within its \u003ccode class=\"option\"\u003e-t\u003c/code\u003e. And, while \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e flag will also dump subsidiary objects (such as indexes) of the selected table(s), \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e flag does not include such subsidiary objects.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIn versions prior to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, this flag matched only tables, not any other type of relation.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore named trigger only. Multiple triggers may be specified with multiple \u003ccode class=\"option\"\u003e-T\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies verbose mode. This will cause \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003ePrevent restoration of access privileges (grant/revoke commands).\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExecute the restore as a single transaction (that is, wrap the emitted commands in \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e). This ensures that either all the commands complete successfully, or no changes are applied. This option implies \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option is relevant only when performing a restore without schema. It instructs \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003cp\u003ePresently, the commands emitted for \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e must be done as superuser. So you should also specify a superuser name with \u003ccode class=\"option\"\u003e-S\u003c/code\u003e or, preferably, run \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e as a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e superuser.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--enable-row-security\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option is relevant only when restoring the contents of a table which has row security. By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will set \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e 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 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to set \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 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.\u003c/p\u003e\n\u003cp\u003eNote that this option currently also requires the dump be in \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e format, as \u003ccode class=\"command\"\u003eCOPY FROM\u003c/code\u003e does not support row security.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e for including objects in schemas, \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e for excluding objects in schemas, \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e for restoring named functions, \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e for restoring named indexes, \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e for restoring named tables or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e for restoring triggers. To read from \u003ccode class=\"literal\"\u003eSTDIN\u003c/code\u003e, use \u003ccode class=\"filename\"\u003e-\u003c/code\u003e as the filename. The \u003ccode class=\"option\"\u003e--filter\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eThe file lists one database pattern per row, with the following format:\u003c/p\u003e\n\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\n\u003cp\u003eThe 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:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003efunction\u003c/code\u003e: functions, works like the \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eindex\u003c/code\u003e: indexes, works like the \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--indexes\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eschema\u003c/code\u003e: schemas, works like the \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e and \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e options.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etable\u003c/code\u003e: tables, works like the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etrigger\u003c/code\u003e: triggers, works like the \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eLines starting with \u003ccode class=\"literal\"\u003e#\u003c/code\u003e are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003ePatterns\u003c/a\u003e for how to perform quoting in patterns.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003ccode class=\"literal\"\u003eDROP ... IF EXISTS\u003c/code\u003e commands to drop objects in \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e mode. This suppresses \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edoes not exist\u003c/span\u003e”\u003c/span\u003e errors that might otherwise be reported. This option is not valid unless \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also specified.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-comments\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore comments, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore data, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-for-failed-tables\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy 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 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extensions such as \u003cspan class=\"productname\"\u003ePostGIS\u003c/span\u003e might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them.\u003c/p\u003e\n\u003cp\u003eThis option is effective only when restoring directly into a database, not when producing SQL script output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-policies\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore row security policies, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-publications\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore publications, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-schema\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore schema (data definitions), even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-security-labels\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore security labels, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore statistics, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-subscriptions\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore subscriptions, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-table-access-method\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-tablespaces\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eUse the provided string as the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e \u003ccode class=\"command\"\u003e\\restrict\u003c/code\u003e key in the dump output. This can only be specified for SQL script output, i.e., when the \u003ccode class=\"option\"\u003e--file\u003c/code\u003e option is used. If no restrict key is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will generate a random one as needed. Keys may contain only alphanumeric characters.\u003c/p\u003e\n\u003cp\u003eThis 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 \u003cspan class=\"application\"\u003epsql\u003c/span\u003e with the dump output.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eOnly restore the named section. The section name can be \u003ccode class=\"option\"\u003epre-data\u003c/code\u003e, \u003ccode class=\"option\"\u003edata\u003c/code\u003e, or \u003ccode class=\"option\"\u003epost-data\u003c/code\u003e. This option can be specified more than once to select multiple sections. The default is to restore all sections.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutput commands to restore statistics, if the archive contains them. This is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRestore only the statistics, not schema (data definitions) or data.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--strict-names\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequire that each schema (\u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e) and table (\u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e) qualifier match at least one schema/table in the file to be restored.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExecute the restore as a series of transactions, each processing up to \u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e database objects. This option implies \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e offers an intermediate choice between the default behavior (one transaction per SQL command) and \u003ccode class=\"option\"\u003e-1\u003c/code\u003e/\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e (one transaction for all restored objects). While \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e with a size of a few thousand objects offers nearly the same performance benefits while capping the amount of lock table space needed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-set-session-authorization\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutput SQL-standard \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e commands instead of \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e also accepts the following command line arguments for connection parameters:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies 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 \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eUser name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to prompt for a password before connecting to a database.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies a role name to be used to perform the restore. This option causes \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to issue a \u003ccode class=\"command\"\u003eSET ROLE\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e command after connecting to the database. It is useful when the authenticated user (specified by \u003ccode class=\"option\"\u003e-U\u003c/code\u003e) lacks privileges needed by \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, also uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (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 \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e when a database name is not supplied.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DIAGNOSTICS\"\u003e\n\u003ch2\u003eDiagnostics\u003c/h2\u003e\n\u003cp\u003eWhen a direct database connection is specified using the \u003ccode class=\"option\"\u003e-d\u003c/code\u003e option, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e internally executes SQL statements. If you have problems running \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, make sure you are able to select information from the database using, for 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 settings and environment variables used by the \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e front-end library will apply.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-NOTES\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eIf your installation has any local additions to the \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e database, be careful to load the output of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e into a truly empty database; otherwise you are likely to get errors due to duplicate definitions of the added objects. To make an empty database without any local additions, copy from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eCREATE DATABASE foo WITH TEMPLATE template0;\n\u003c/pre\u003e\n\u003cp\u003eThe limitations of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e are detailed below.\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eWhen restoring data to a pre-existing table and the option \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e emits commands to disable triggers on user tables before inserting the data, then emits commands to re-enable them after the data has been inserted. If the restore is stopped in the middle, the system catalogs might be left in the wrong state.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore large objects selectively; for instance, only those for a specific table. If an archive contains large objects, then all large objects will be restored, or none of them if they are excluded via \u003ccode class=\"option\"\u003e-L\u003c/code\u003e, \u003ccode class=\"option\"\u003e-t\u003c/code\u003e, or other options.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eSee 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 limitations of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e will restore optimizer statistics if included in the dump file. If not all statistics were restored, it may be useful to run \u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e on each restored table so the 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 information.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-EXAMPLES\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eAssume we have dumped a database called \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e into a custom-format dump file:\u003c/p\u003e\n\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\n\u003cp\u003eTo drop the database and recreate it from the dump:\u003c/p\u003e\n\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\n\u003cp\u003eThe database named in the \u003ccode class=\"option\"\u003e-d\u003c/code\u003e switch can be any database existing in the cluster; \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e only uses it to issue the \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e command for \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e. With \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, data is always restored into the database name that appears in the dump file.\u003c/p\u003e\n\u003cp\u003eTo restore the dump into a new database called \u003ccode class=\"literal\"\u003enewdb\u003c/code\u003e:\u003c/p\u003e\n\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\n\u003cp\u003eNotice we don't use \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, and instead connect directly to the database to be restored into. Also note that we clone the new database from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, to ensure it is initially empty.\u003c/p\u003e\n\u003cp\u003eTo reorder database items, it is first necessary to dump the table of contents of the archive:\u003c/p\u003e\n\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\n\u003cp\u003eThe listing file consists of a header and one line for each item, e.g.:\u003c/p\u003e\n\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\n\u003cp\u003eSemicolons start a comment, and the numbers at the start of lines refer to the internal archive ID assigned to each item.\u003c/p\u003e\n\u003cp\u003eLines in the file can be commented out, deleted, and reordered. For example:\u003c/p\u003e\n\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\n\u003cp\u003ecould be used as input to \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e and would only restore items 10 and 6, in that order:\u003c/p\u003e\n\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\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.11\"\u003e\n\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\n\u003c/div\u003e\n\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 / --indexes 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"}],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"pg_restore [ connection-option ...] [ option ...] [ filename ]","sources":[{"anchor":"","file":"app-pgrestore.html","label":"18.6 English manual · app-pgrestore.html","sha256":"ac4df6d64f46809a487e98597ad3d3f69abc33de7cd5e5c1537563e2b6d9b5fa","url":"/docs/18/app-pgrestore.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","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"}]},"ManualEvidence":{"manual_path":"app-pgrestore.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"app-pgrestore.html","label":"18.6 English manual · app-pgrestore.html","sha256":"ac4df6d64f46809a487e98597ad3d3f69abc33de7cd5e5c1537563e2b6d9b5fa","url":"/docs/18/app-pgrestore.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","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\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epg_restore\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_restore — restore a \u003cspan\u003ePostgreSQL\u003c/span\u003e database from an archive file created by \u003cspan\u003epg_dump\u003c/span\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\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\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PGRESTORE-DESCRIPTION\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epg_restore\u003c/span\u003e is a utility for restoring a \u003cspan\u003ePostgreSQL\u003c/span\u003e database from an archive 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 formats. It will issue the commands necessary to reconstruct the database to the state it was in at the time it was saved. The archive files also allow \u003cspan\u003epg_restore\u003c/span\u003e to be selective about what is restored, or even to reorder the items prior to being restored. The archive files are designed to be portable across architectures.\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epg_restore\u003c/span\u003e can operate in two modes. If a database name is specified, \u003cspan\u003epg_restore\u003c/span\u003e connects to that database and restores archive contents directly into the database. Otherwise, a script containing the SQL commands necessary to rebuild the database is created and written to a file or standard output. This script output is equivalent to the plain text output format of \u003cspan\u003epg_dump\u003c/span\u003e. Some of the options controlling the output are therefore analogous to \u003cspan\u003epg_dump\u003c/span\u003e options.\u003c/p\u003e\n\u003cp\u003eObviously, \u003cspan\u003epg_restore\u003c/span\u003e cannot restore information that is not present in the archive file. For instance, if the archive was made using the \u003cspan\u003e“\u003cspan\u003edump data as \u003ccode\u003eINSERT\u003c/code\u003e commands\u003c/span\u003e”\u003c/span\u003e option, \u003cspan\u003epg_restore\u003c/span\u003e will not be able to load the data using \u003ccode\u003eCOPY\u003c/code\u003e statements.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eWarning\u003c/h3\u003e\n\u003cp\u003eRestoring a dump causes the destination to execute arbitrary code of the source superusers\u0026#39; choice. Partial dumps and partial restores do not limit that. If the source superusers are not trusted, the dumped SQL statements must be inspected before restoring. Non-plain-text dumps can be inspected by using \u003cspan\u003epg_restore\u003c/span\u003e\u0026#39;s \u003ccode\u003e--file\u003c/code\u003e option. Note that the client running the dump and restore need not trust the source or destination superusers.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PGRESTORE-OPTIONS\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epg_restore\u003c/span\u003e accepts the following command line arguments.\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003cem\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the archive file (or directory, for a directory-format archive) to be restored. If not specified, the standard input is used.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive.\u003c/p\u003e\n\u003cp\u003eThis option is similar to, but for historical reasons not identical to, specifying \u003ccode\u003e--section=data\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eBefore restoring database objects, issue commands to \u003ccode\u003eDROP\u003c/code\u003e 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 \u003ccode\u003e--if-exists\u003c/code\u003e is also specified.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eCreate the database before restoring into it. If \u003ccode\u003e--clean\u003c/code\u003e is also specified, drop and recreate the target database before connecting to it.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode\u003e--create\u003c/code\u003e, \u003cspan\u003epg_restore\u003c/span\u003e also restores the database\u0026#39;s comment if any, and any configuration variable settings that are specific to this database, that is, any \u003ccode\u003eALTER DATABASE ... SET ...\u003c/code\u003e and \u003ccode\u003eALTER ROLE ... IN DATABASE ... SET ...\u003c/code\u003e commands that mention this database. Access privileges for the database itself are also restored, unless \u003ccode\u003e--no-acl\u003c/code\u003e is specified.\u003c/p\u003e\n\u003cp\u003eWhen this option is used, the database named with \u003ccode\u003e-d\u003c/code\u003e is used only to issue the initial \u003ccode\u003eDROP DATABASE\u003c/code\u003e and \u003ccode\u003eCREATE DATABASE\u003c/code\u003e commands. All data is restored into the database name that appears in the archive.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eConnect to database \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e and restore directly into the database. The \u003cem\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can be a \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" rel=\"nofollow\"\u003econnection string\u003c/a\u003e. If so, connection string parameters will override any conflicting command line options.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExit 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify output file for generated script, or for the listing when used with \u003ccode\u003e-l\u003c/code\u003e. Use \u003ccode\u003e-\u003c/code\u003e for \u003cspan\u003estdout\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify format of the archive. It is not necessary to specify the format, since \u003cspan\u003epg_restore\u003c/span\u003e will determine the format automatically. If specified, it can be one of the following:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is in the custom format of \u003cspan\u003epg_dump\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is a directory archive.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is a \u003ccode\u003etar\u003c/code\u003e archive.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore definition of named index only. Multiple indexes may be specified with multiple \u003ccode\u003e-I\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRun the most time-consuming steps of \u003cspan\u003epg_restore\u003c/span\u003e — those that load data, create indexes, or create constraints — concurrently, using up to \u003cem\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e 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.\u003c/p\u003e\n\u003cp\u003eEach job is one process or one thread, depending on the operating system, and uses a separate connection to the server.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003cp\u003eOnly 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 \u003ccode\u003e--single-transaction\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eList the table of contents of the archive. The output of this operation can be used as input to the \u003ccode\u003e-L\u003c/code\u003e option. Note that if filtering switches such as \u003ccode\u003e-n\u003c/code\u003e or \u003ccode\u003e-t\u003c/code\u003e are used with \u003ccode\u003e-l\u003c/code\u003e, they will restrict the items listed.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only those archive elements that are listed in \u003cem\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e, and restore them in the order they appear in the file. Note that if filtering switches such as \u003ccode\u003e-n\u003c/code\u003e or \u003ccode\u003e-t\u003c/code\u003e are used with \u003ccode\u003e-L\u003c/code\u003e, they will further restrict the items restored.\u003c/p\u003e\n\u003cp\u003e\u003cem\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e is normally created by editing the output of a previous \u003ccode\u003e-l\u003c/code\u003e operation. Lines can be moved or removed, and can also be commented out by placing a semicolon (\u003ccode\u003e;\u003c/code\u003e) at the start of the line. See below for examples.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only objects that are in the named schema. Multiple schemas may be specified with multiple \u003ccode\u003e-n\u003c/code\u003e switches. This can be combined with the \u003ccode\u003e-t\u003c/code\u003e option to restore just a specific table.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDo not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple \u003ccode\u003e-N\u003c/code\u003e switches.\u003c/p\u003e\n\u003cp\u003eWhen both \u003ccode\u003e-n\u003c/code\u003e and \u003ccode\u003e-N\u003c/code\u003e are given for the same schema name, the \u003ccode\u003e-N\u003c/code\u003e switch wins and the schema is excluded.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to set ownership of objects to match the original database. By default, \u003cspan\u003epg_restore\u003c/span\u003e issues \u003ccode\u003eALTER OWNER\u003c/code\u003e or \u003ccode\u003eSET SESSION AUTHORIZATION\u003c/code\u003e 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 \u003ccode\u003e-O\u003c/code\u003e, any user name can be used for the initial connection, and this user will own all the created objects.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore the named function only. Be careful to spell the function name and arguments exactly as they appear in the dump file\u0026#39;s table of contents. Multiple functions may be specified with multiple \u003ccode\u003e-P\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThis option is obsolete but still accepted for backwards compatibility.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only the schema (data definitions), not data, to the extent that schema entries are present in the archive.\u003c/p\u003e\n\u003cp\u003eThis option cannot be used with \u003ccode\u003e--data-only\u003c/code\u003e or \u003ccode\u003e--statistics-only\u003c/code\u003e. It is similar to, but for historical reasons not identical to, specifying \u003ccode\u003e--section=pre-data --section=post-data --no-statistics\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e(Do not confuse this with the \u003ccode\u003e--schema\u003c/code\u003e option, which uses the word \u003cspan\u003e“\u003cspan\u003eschema\u003c/span\u003e”\u003c/span\u003e in a different meaning.)\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify the superuser user name to use when disabling triggers. This is relevant only if \u003ccode\u003e--disable-triggers\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore definition and/or data of only the named table. For this purpose, \u003cspan\u003e“\u003cspan\u003etable\u003c/span\u003e”\u003c/span\u003e includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple \u003ccode\u003e-t\u003c/code\u003e switches. This option can be combined with the \u003ccode\u003e-n\u003c/code\u003e option to specify table(s) in a particular schema.\u003c/p\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhen \u003ccode\u003e-t\u003c/code\u003e is specified, \u003cspan\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis flag does not behave identically to the \u003ccode\u003e-t\u003c/code\u003e flag of \u003cspan\u003epg_dump\u003c/span\u003e. There is not currently any provision for wild-card matching in \u003cspan\u003epg_restore\u003c/span\u003e, nor can you include a schema name within its \u003ccode\u003e-t\u003c/code\u003e. And, while \u003cspan\u003epg_dump\u003c/span\u003e\u0026#39;s \u003ccode\u003e-t\u003c/code\u003e flag will also dump subsidiary objects (such as indexes) of the selected table(s), \u003cspan\u003epg_restore\u003c/span\u003e\u0026#39;s \u003ccode\u003e-t\u003c/code\u003e flag does not include such subsidiary objects.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch3\u003eNote\u003c/h3\u003e\n\u003cp\u003eIn versions prior to \u003cspan\u003ePostgreSQL\u003c/span\u003e 9.6, this flag matched only tables, not any other type of relation.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore named trigger only. Multiple triggers may be specified with multiple \u003ccode\u003e-T\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies verbose mode. This will cause \u003cspan\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan\u003epg_restore\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003ePrevent restoration of access privileges (grant/revoke commands).\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExecute the restore as a single transaction (that is, wrap the emitted commands in \u003ccode\u003eBEGIN\u003c/code\u003e/\u003ccode\u003eCOMMIT\u003c/code\u003e). This ensures that either all the commands complete successfully, or no changes are applied. This option implies \u003ccode\u003e--exit-on-error\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--disable-triggers\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option is relevant only when performing a restore without schema. It instructs \u003cspan\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003cp\u003ePresently, the commands emitted for \u003ccode\u003e--disable-triggers\u003c/code\u003e must be done as superuser. So you should also specify a superuser name with \u003ccode\u003e-S\u003c/code\u003e or, preferably, run \u003cspan\u003epg_restore\u003c/span\u003e as a \u003cspan\u003ePostgreSQL\u003c/span\u003e superuser.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--enable-row-security\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option is relevant only when restoring the contents of a table which has row security. By default, \u003cspan\u003epg_restore\u003c/span\u003e will set \u003ca href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\" rel=\"nofollow\"\u003erow_security\u003c/a\u003e 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 \u003cspan\u003epg_restore\u003c/span\u003e to set \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 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.\u003c/p\u003e\n\u003cp\u003eNote that this option currently also requires the dump be in \u003ccode\u003eINSERT\u003c/code\u003e format, as \u003ccode\u003eCOPY FROM\u003c/code\u003e does not support row security.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as \u003ccode\u003e-n\u003c/code\u003e/\u003ccode\u003e--schema\u003c/code\u003e for including objects in schemas, \u003ccode\u003e-N\u003c/code\u003e/\u003ccode\u003e--exclude-schema\u003c/code\u003e for excluding objects in schemas, \u003ccode\u003e-P\u003c/code\u003e/\u003ccode\u003e--function\u003c/code\u003e for restoring named functions, \u003ccode\u003e-I\u003c/code\u003e/\u003ccode\u003e--index\u003c/code\u003e for restoring named indexes, \u003ccode\u003e-t\u003c/code\u003e/\u003ccode\u003e--table\u003c/code\u003e for restoring named tables or \u003ccode\u003e-T\u003c/code\u003e/\u003ccode\u003e--trigger\u003c/code\u003e for restoring triggers. To read from \u003ccode\u003eSTDIN\u003c/code\u003e, use \u003ccode\u003e-\u003c/code\u003e as the filename. The \u003ccode\u003e--filter\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eThe file lists one database pattern per row, with the following format:\u003c/p\u003e\n\u003cpre\u003e{ include | exclude } { function | index | schema | table | trigger } \u003cem\u003e\u003ccode\u003ePATTERN\u003c/code\u003e\u003c/em\u003e\n\u003c/pre\u003e\n\u003cp\u003eThe 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:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003efunction\u003c/code\u003e: functions, works like the \u003ccode\u003e-P\u003c/code\u003e/\u003ccode\u003e--function\u003c/code\u003e option. This keyword can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eindex\u003c/code\u003e: indexes, works like the \u003ccode\u003e-I\u003c/code\u003e/\u003ccode\u003e--indexes\u003c/code\u003e option. This keyword can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003eschema\u003c/code\u003e: schemas, works like the \u003ccode\u003e-n\u003c/code\u003e/\u003ccode\u003e--schema\u003c/code\u003e and \u003ccode\u003e-N\u003c/code\u003e/\u003ccode\u003e--exclude-schema\u003c/code\u003e options.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003etable\u003c/code\u003e: tables, works like the \u003ccode\u003e-t\u003c/code\u003e/\u003ccode\u003e--table\u003c/code\u003e option. This keyword can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003ccode\u003etrigger\u003c/code\u003e: triggers, works like the \u003ccode\u003e-T\u003c/code\u003e/\u003ccode\u003e--trigger\u003c/code\u003e option. This keyword can only be used with the \u003ccode\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eLines starting with \u003ccode\u003e#\u003c/code\u003e are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See \u003ca href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\" rel=\"nofollow\"\u003ePatterns\u003c/a\u003e for how to perform quoting in patterns.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--if-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003ccode\u003eDROP ... IF EXISTS\u003c/code\u003e commands to drop objects in \u003ccode\u003e--clean\u003c/code\u003e mode. This suppresses \u003cspan\u003e“\u003cspan\u003edoes not exist\u003c/span\u003e”\u003c/span\u003e errors that might otherwise be reported. This option is not valid unless \u003ccode\u003e--clean\u003c/code\u003e is also specified.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-comments\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore comments, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-data\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore data, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-data-for-failed-tables\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy 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 \u003cspan\u003ePostgreSQL\u003c/span\u003e extensions such as \u003cspan\u003ePostGIS\u003c/span\u003e might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them.\u003c/p\u003e\n\u003cp\u003eThis option is effective only when restoring directly into a database, not when producing SQL script output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-policies\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore row security policies, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-publications\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore publications, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-schema\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore schema (data definitions), even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-security-labels\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore security labels, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore statistics, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-subscriptions\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore subscriptions, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-table-access-method\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-tablespaces\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eUse the provided string as the \u003cspan\u003epsql\u003c/span\u003e \u003ccode\u003e\\restrict\u003c/code\u003e key in the dump output. This can only be specified for SQL script output, i.e., when the \u003ccode\u003e--file\u003c/code\u003e option is used. If no restrict key is specified, \u003cspan\u003epg_restore\u003c/span\u003e will generate a random one as needed. Keys may contain only alphanumeric characters.\u003c/p\u003e\n\u003cp\u003eThis 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 \u003cspan\u003epsql\u003c/span\u003e with the dump output.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eOnly restore the named section. The section name can be \u003ccode\u003epre-data\u003c/code\u003e, \u003ccode\u003edata\u003c/code\u003e, or \u003ccode\u003epost-data\u003c/code\u003e. This option can be specified more than once to select multiple sections. The default is to restore all sections.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutput commands to restore statistics, if the archive contains them. This is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--statistics-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRestore only the statistics, not schema (data definitions) or data.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--strict-names\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequire that each schema (\u003ccode\u003e-n\u003c/code\u003e/\u003ccode\u003e--schema\u003c/code\u003e) and table (\u003ccode\u003e-t\u003c/code\u003e/\u003ccode\u003e--table\u003c/code\u003e) qualifier match at least one schema/table in the file to be restored.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExecute the restore as a series of transactions, each processing up to \u003cem\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e database objects. This option implies \u003ccode\u003e--exit-on-error\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode\u003e--transaction-size\u003c/code\u003e offers an intermediate choice between the default behavior (one transaction per SQL command) and \u003ccode\u003e-1\u003c/code\u003e/\u003ccode\u003e--single-transaction\u003c/code\u003e (one transaction for all restored objects). While \u003ccode\u003e--single-transaction\u003c/code\u003e 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\u0026#39;s lock table space. Using \u003ccode\u003e--transaction-size\u003c/code\u003e with a size of a few thousand objects offers nearly the same performance benefits while capping the amount of lock table space needed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--use-set-session-authorization\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutput SQL-standard \u003ccode\u003eSET SESSION AUTHORIZATION\u003c/code\u003e commands instead of \u003ccode\u003eALTER OWNER\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan\u003epg_restore\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan\u003epg_restore\u003c/span\u003e also accepts the following command line arguments for connection parameters:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies 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 \u003ccode\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eUser name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode\u003e.pgpass\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan\u003epg_restore\u003c/span\u003e to prompt for a password before connecting to a database.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan\u003epg_restore\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan\u003epg_restore\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies a role name to be used to perform the restore. This option causes \u003cspan\u003epg_restore\u003c/span\u003e to issue a \u003ccode\u003eSET ROLE\u003c/code\u003e \u003cem\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e command after connecting to the database. It is useful when the authenticated user (specified by \u003ccode\u003e-U\u003c/code\u003e) lacks privileges needed by \u003cspan\u003epg_restore\u003c/span\u003e, 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.19.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and \u003ccode\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan\u003ePostgreSQL\u003c/span\u003e utilities, also uses the environment variables supported by \u003cspan\u003elibpq\u003c/span\u003e (see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e). However, it does not read \u003ccode\u003ePGDATABASE\u003c/code\u003e when a database name is not supplied.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PGRESTORE-DIAGNOSTICS\"\u003e\n\u003ch2\u003eDiagnostics\u003c/h2\u003e\n\u003cp\u003eWhen a direct database connection is specified using the \u003ccode\u003e-d\u003c/code\u003e option, \u003cspan\u003epg_restore\u003c/span\u003e internally executes SQL statements. If you have problems running \u003cspan\u003epg_restore\u003c/span\u003e, make sure you are able to select information from the database using, for 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 settings and environment variables used by the \u003cspan\u003elibpq\u003c/span\u003e front-end library will apply.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PGRESTORE-NOTES\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eIf your installation has any local additions to the \u003ccode\u003etemplate1\u003c/code\u003e database, be careful to load the output of \u003cspan\u003epg_restore\u003c/span\u003e into a truly empty database; otherwise you are likely to get errors due to duplicate definitions of the added objects. To make an empty database without any local additions, copy from \u003ccode\u003etemplate0\u003c/code\u003e not \u003ccode\u003etemplate1\u003c/code\u003e, for example:\u003c/p\u003e\n\u003cpre\u003eCREATE DATABASE foo WITH TEMPLATE template0;\n\u003c/pre\u003e\n\u003cp\u003eThe limitations of \u003cspan\u003epg_restore\u003c/span\u003e are detailed below.\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eWhen restoring data to a pre-existing table and the option \u003ccode\u003e--disable-triggers\u003c/code\u003e is used, \u003cspan\u003epg_restore\u003c/span\u003e emits commands to disable triggers on user tables before inserting the data, then emits commands to re-enable them after the data has been inserted. If the restore is stopped in the middle, the system catalogs might be left in the wrong state.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003cspan\u003epg_restore\u003c/span\u003e cannot restore large objects selectively; for instance, only those for a specific table. If an archive contains large objects, then all large objects will be restored, or none of them if they are excluded via \u003ccode\u003e-L\u003c/code\u003e, \u003ccode\u003e-t\u003c/code\u003e, or other options.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eSee 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 limitations of \u003cspan\u003epg_dump\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode\u003epg_restore\u003c/code\u003e will restore optimizer statistics if included in the dump file. If not all statistics were restored, it may be useful to run \u003ccode\u003eANALYZE\u003c/code\u003e on each restored table so the 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 information.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"APP-PGRESTORE-EXAMPLES\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eAssume we have dumped a database called \u003ccode\u003emydb\u003c/code\u003e into a custom-format dump file:\u003c/p\u003e\n\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\n\u003cp\u003eTo drop the database and recreate it from the dump:\u003c/p\u003e\n\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\n\u003cp\u003eThe database named in the \u003ccode\u003e-d\u003c/code\u003e switch can be any database existing in the cluster; \u003cspan\u003epg_restore\u003c/span\u003e only uses it to issue the \u003ccode\u003eCREATE DATABASE\u003c/code\u003e command for \u003ccode\u003emydb\u003c/code\u003e. With \u003ccode\u003e-C\u003c/code\u003e, data is always restored into the database name that appears in the dump file.\u003c/p\u003e\n\u003cp\u003eTo restore the dump into a new database called \u003ccode\u003enewdb\u003c/code\u003e:\u003c/p\u003e\n\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\n\u003cp\u003eNotice we don\u0026#39;t use \u003ccode\u003e-C\u003c/code\u003e, and instead connect directly to the database to be restored into. Also note that we clone the new database from \u003ccode\u003etemplate0\u003c/code\u003e not \u003ccode\u003etemplate1\u003c/code\u003e, to ensure it is initially empty.\u003c/p\u003e\n\u003cp\u003eTo reorder database items, it is first necessary to dump the table of contents of the archive:\u003c/p\u003e\n\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\n\u003cp\u003eThe listing file consists of a header and one line for each item, e.g.:\u003c/p\u003e\n\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\n\u003cp\u003eSemicolons start a comment, and the numbers at the start of lines refer to the internal archive ID assigned to each item.\u003c/p\u003e\n\u003cp\u003eLines in the file can be commented out, deleted, and reordered. For example:\u003c/p\u003e\n\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\n\u003cp\u003ecould be used as input to \u003cspan\u003epg_restore\u003c/span\u003e and would only restore items 10 and 6, in that order:\u003c/p\u003e\n\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\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.19.11\"\u003e\n\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\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"bfbe46ce474319b4c88bd7d35213051957c20a15d827f6d2ae885efbca59cc74","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\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_restore — restore a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an archive file created by \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\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\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DESCRIPTION\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e is a utility for restoring a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database from an archive 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 formats. It will issue the commands necessary to reconstruct the database to the state it was in at the time it was saved. The archive files also allow \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to be selective about what is restored, or even to reorder the items prior to being restored. The archive files are designed to be portable across architectures.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e can operate in two modes. If a database name is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e connects to that database and restores archive contents directly into the database. Otherwise, a script containing the SQL commands necessary to rebuild the database is created and written to a file or standard output. This script output is equivalent to the plain text output format of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e. Some of the options controlling the output are therefore analogous to \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e options.\u003c/p\u003e\n\u003cp\u003eObviously, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore information that is not present in the archive file. For instance, if the archive was made using the \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edump data as \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e commands\u003c/span\u003e”\u003c/span\u003e option, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will not be able to load the data using \u003ccode class=\"command\"\u003eCOPY\u003c/code\u003e statements.\u003c/p\u003e\n\u003cdiv class=\"warning\"\u003e\n\u003ch3 class=\"title\"\u003eWarning\u003c/h3\u003e\n\u003cp\u003eRestoring a dump causes the destination to execute arbitrary code of the source superusers' choice. Partial dumps and partial restores do not limit that. If the source superusers are not trusted, the dumped SQL statements must be inspected before restoring. Non-plain-text dumps can be inspected by using \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e--file\u003c/code\u003e option. Note that the client running the dump and restore need not trust the source or destination superusers.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-OPTIONS\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e accepts the following command line arguments.\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003efilename\u003c/code\u003e\u003c/em\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the location of the archive file (or directory, for a directory-format archive) to be restored. If not specified, the standard input is used.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are restored, if present in the archive.\u003c/p\u003e\n\u003cp\u003eThis option is similar to, but for historical reasons not identical to, specifying \u003ccode class=\"option\"\u003e--section=data\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eBefore restoring database objects, issue commands to \u003ccode class=\"command\"\u003eDROP\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e is also specified.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eCreate the database before restoring into it. If \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also specified, drop and recreate the target database before connecting to it.\u003c/p\u003e\n\u003cp\u003eWith \u003ccode class=\"option\"\u003e--create\u003c/code\u003e, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e also restores the database's comment if any, and any configuration variable settings that are specific to this database, that is, any \u003ccode class=\"command\"\u003eALTER DATABASE ... SET ...\u003c/code\u003e and \u003ccode class=\"command\"\u003eALTER ROLE ... IN DATABASE ... SET ...\u003c/code\u003e commands that mention this database. Access privileges for the database itself are also restored, unless \u003ccode class=\"option\"\u003e--no-acl\u003c/code\u003e is specified.\u003c/p\u003e\n\u003cp\u003eWhen this option is used, the database named with \u003ccode class=\"option\"\u003e-d\u003c/code\u003e is used only to issue the initial \u003ccode class=\"command\"\u003eDROP DATABASE\u003c/code\u003e and \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e commands. All data is restored into the database name that appears in the archive.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eConnect to database \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e and restore directly into the database. The \u003cem class=\"replaceable\"\u003e\u003ccode\u003edbname\u003c/code\u003e\u003c/em\u003e can be a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e. If so, connection string parameters will override any conflicting command line options.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExit 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify output file for generated script, or for the listing when used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e. Use \u003ccode class=\"literal\"\u003e-\u003c/code\u003e for \u003cspan class=\"systemitem\"\u003estdout\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify format of the archive. It is not necessary to specify the format, since \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will determine the format automatically. If specified, it can be one of the following:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is in the custom format of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is a directory archive.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThe archive is a \u003ccode class=\"command\"\u003etar\u003c/code\u003e archive.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore definition of named index only. Multiple indexes may be specified with multiple \u003ccode class=\"option\"\u003e-I\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRun the most time-consuming steps of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e — those that load data, create indexes, or create constraints — concurrently, using up to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enumber-of-jobs\u003c/code\u003e\u003c/em\u003e 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.\u003c/p\u003e\n\u003cp\u003eEach job is one process or one thread, depending on the operating system, and uses a separate connection to the server.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003cp\u003eOnly 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 \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eList the table of contents of the archive. The output of this operation can be used as input to the \u003ccode class=\"option\"\u003e-L\u003c/code\u003e option. Note that if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are used with \u003ccode class=\"option\"\u003e-l\u003c/code\u003e, they will restrict the items listed.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore 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 order they appear in the file. Note that if filtering switches such as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e or \u003ccode class=\"option\"\u003e-t\u003c/code\u003e are used with \u003ccode class=\"option\"\u003e-L\u003c/code\u003e, they will further restrict the items restored.\u003c/p\u003e\n\u003cp\u003e\u003cem class=\"replaceable\"\u003e\u003ccode\u003elist-file\u003c/code\u003e\u003c/em\u003e is normally created by editing the output of a previous \u003ccode class=\"option\"\u003e-l\u003c/code\u003e operation. Lines can be moved or removed, and can also be commented out by placing a semicolon (\u003ccode class=\"literal\"\u003e;\u003c/code\u003e) at the start of the line. See below for examples.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only objects that are in the named schema. Multiple schemas may be specified with multiple \u003ccode class=\"option\"\u003e-n\u003c/code\u003e switches. This can be combined with the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e option to restore just a specific table.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDo not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switches.\u003c/p\u003e\n\u003cp\u003eWhen both \u003ccode class=\"option\"\u003e-n\u003c/code\u003e and \u003ccode class=\"option\"\u003e-N\u003c/code\u003e are given for the same schema name, the \u003ccode class=\"option\"\u003e-N\u003c/code\u003e switch wins and the schema is excluded.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to set ownership of objects to match the original database. By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e issues \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e or \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e-O\u003c/code\u003e, any user name can be used for the initial connection, and this user will own all the created objects.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore 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 \u003ccode class=\"option\"\u003e-P\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eThis option is obsolete but still accepted for backwards compatibility.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore only the schema (data definitions), not data, to the extent that schema entries are present in the archive.\u003c/p\u003e\n\u003cp\u003eThis option cannot be used with \u003ccode class=\"option\"\u003e--data-only\u003c/code\u003e or \u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e. It is similar to, but for historical reasons not identical to, specifying \u003ccode class=\"option\"\u003e--section=pre-data --section=post-data --no-statistics\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e(Do not confuse this with the \u003ccode class=\"option\"\u003e--schema\u003c/code\u003e option, which uses the word \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eschema\u003c/span\u003e”\u003c/span\u003e in a different meaning.)\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify the superuser user name to use when disabling triggers. This is relevant only if \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore definition and/or data of only the named table. For this purpose, \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003etable\u003c/span\u003e”\u003c/span\u003e includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple \u003ccode class=\"option\"\u003e-t\u003c/code\u003e switches. This option can be combined with the \u003ccode class=\"option\"\u003e-n\u003c/code\u003e option to specify table(s) in a particular schema.\u003c/p\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eWhen \u003ccode class=\"option\"\u003e-t\u003c/code\u003e is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eThis flag does not behave identically to the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e flag of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e. There is not currently any provision for wild-card matching in \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, nor can you include a schema name within its \u003ccode class=\"option\"\u003e-t\u003c/code\u003e. And, while \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e flag will also dump subsidiary objects (such as indexes) of the selected table(s), \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e's \u003ccode class=\"option\"\u003e-t\u003c/code\u003e flag does not include such subsidiary objects.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"note\"\u003e\n\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\n\u003cp\u003eIn versions prior to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e 9.6, this flag matched only tables, not any other type of relation.\u003c/p\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eRestore named trigger only. Multiple triggers may be specified with multiple \u003ccode class=\"option\"\u003e-T\u003c/code\u003e switches.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies verbose mode. This will cause \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003ePrint the \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e version and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003ePrevent restoration of access privileges (grant/revoke commands).\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExecute the restore as a single transaction (that is, wrap the emitted commands in \u003ccode class=\"command\"\u003eBEGIN\u003c/code\u003e/\u003ccode class=\"command\"\u003eCOMMIT\u003c/code\u003e). This ensures that either all the commands complete successfully, or no changes are applied. This option implies \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option is relevant only when performing a restore without schema. It instructs \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e 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.\u003c/p\u003e\n\u003cp\u003ePresently, the commands emitted for \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e must be done as superuser. So you should also specify a superuser name with \u003ccode class=\"option\"\u003e-S\u003c/code\u003e or, preferably, run \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e as a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e superuser.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--enable-row-security\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option is relevant only when restoring the contents of a table which has row security. By default, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will set \u003ca class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\"\u003erow_security\u003c/a\u003e 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 \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to set \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 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.\u003c/p\u003e\n\u003cp\u003eNote that this option currently also requires the dump be in \u003ccode class=\"command\"\u003eINSERT\u003c/code\u003e format, as \u003ccode class=\"command\"\u003eCOPY FROM\u003c/code\u003e does not support row security.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecify a filename from which to read patterns for objects excluded or included from restore. The patterns are interpreted according to the same rules as \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e for including objects in schemas, \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e for excluding objects in schemas, \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e for restoring named functions, \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--index\u003c/code\u003e for restoring named indexes, \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e for restoring named tables or \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e for restoring triggers. To read from \u003ccode class=\"literal\"\u003eSTDIN\u003c/code\u003e, use \u003ccode class=\"filename\"\u003e-\u003c/code\u003e as the filename. The \u003ccode class=\"option\"\u003e--filter\u003c/code\u003e 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.\u003c/p\u003e\n\u003cp\u003eThe file lists one database pattern per row, with the following format:\u003c/p\u003e\n\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\n\u003cp\u003eThe 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:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003efunction\u003c/code\u003e: functions, works like the \u003ccode class=\"option\"\u003e-P\u003c/code\u003e/\u003ccode class=\"option\"\u003e--function\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eindex\u003c/code\u003e: indexes, works like the \u003ccode class=\"option\"\u003e-I\u003c/code\u003e/\u003ccode class=\"option\"\u003e--indexes\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003eschema\u003c/code\u003e: schemas, works like the \u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e and \u003ccode class=\"option\"\u003e-N\u003c/code\u003e/\u003ccode class=\"option\"\u003e--exclude-schema\u003c/code\u003e options.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etable\u003c/code\u003e: tables, works like the \u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003ccode class=\"literal\"\u003etrigger\u003c/code\u003e: triggers, works like the \u003ccode class=\"option\"\u003e-T\u003c/code\u003e/\u003ccode class=\"option\"\u003e--trigger\u003c/code\u003e option. This keyword can only be used with the \u003ccode class=\"literal\"\u003einclude\u003c/code\u003e keyword.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eLines starting with \u003ccode class=\"literal\"\u003e#\u003c/code\u003e are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See \u003ca class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\"\u003ePatterns\u003c/a\u003e for how to perform quoting in patterns.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--if-exists\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eUse \u003ccode class=\"literal\"\u003eDROP ... IF EXISTS\u003c/code\u003e commands to drop objects in \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e mode. This suppresses \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003edoes not exist\u003c/span\u003e”\u003c/span\u003e errors that might otherwise be reported. This option is not valid unless \u003ccode class=\"option\"\u003e--clean\u003c/code\u003e is also specified.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-comments\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore comments, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore data, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-data-for-failed-tables\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy 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 \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e extensions such as \u003cspan class=\"productname\"\u003ePostGIS\u003c/span\u003e might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them.\u003c/p\u003e\n\u003cp\u003eThis option is effective only when restoring directly into a database, not when producing SQL script output.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-policies\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore row security policies, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-publications\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore publications, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-schema\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore schema (data definitions), even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-security-labels\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore security labels, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore statistics, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-subscriptions\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to restore subscriptions, even if the archive contains them.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-table-access-method\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-tablespaces\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDo not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eUse the provided string as the \u003cspan class=\"application\"\u003epsql\u003c/span\u003e \u003ccode class=\"command\"\u003e\\restrict\u003c/code\u003e key in the dump output. This can only be specified for SQL script output, i.e., when the \u003ccode class=\"option\"\u003e--file\u003c/code\u003e option is used. If no restrict key is specified, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will generate a random one as needed. Keys may contain only alphanumeric characters.\u003c/p\u003e\n\u003cp\u003eThis 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 \u003cspan class=\"application\"\u003epsql\u003c/span\u003e with the dump output.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eOnly restore the named section. The section name can be \u003ccode class=\"option\"\u003epre-data\u003c/code\u003e, \u003ccode class=\"option\"\u003edata\u003c/code\u003e, or \u003ccode class=\"option\"\u003epost-data\u003c/code\u003e. This option can be specified more than once to select multiple sections. The default is to restore all sections.\u003c/p\u003e\n\u003cp\u003eThe 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutput commands to restore statistics, if the archive contains them. This is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--statistics-only\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRestore only the statistics, not schema (data definitions) or data.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--strict-names\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequire that each schema (\u003ccode class=\"option\"\u003e-n\u003c/code\u003e/\u003ccode class=\"option\"\u003e--schema\u003c/code\u003e) and table (\u003ccode class=\"option\"\u003e-t\u003c/code\u003e/\u003ccode class=\"option\"\u003e--table\u003c/code\u003e) qualifier match at least one schema/table in the file to be restored.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eExecute the restore as a series of transactions, each processing up to \u003cem class=\"replaceable\"\u003e\u003ccode\u003eN\u003c/code\u003e\u003c/em\u003e database objects. This option implies \u003ccode class=\"option\"\u003e--exit-on-error\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003e\u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e offers an intermediate choice between the default behavior (one transaction per SQL command) and \u003ccode class=\"option\"\u003e-1\u003c/code\u003e/\u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e (one transaction for all restored objects). While \u003ccode class=\"option\"\u003e--single-transaction\u003c/code\u003e 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 \u003ccode class=\"option\"\u003e--transaction-size\u003c/code\u003e with a size of a few thousand objects offers nearly the same performance benefits while capping the amount of lock table space needed.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--use-set-session-authorization\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eOutput SQL-standard \u003ccode class=\"command\"\u003eSET SESSION AUTHORIZATION\u003c/code\u003e commands instead of \u003ccode class=\"command\"\u003eALTER OWNER\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eShow help about \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e command line arguments, and exit.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e also accepts the following command line arguments for connection parameters:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies 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 \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eUser name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eNever issue a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e 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.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eForce \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to prompt for a password before connecting to a database.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eSpecifies a role name to be used to perform the restore. This option causes \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e to issue a \u003ccode class=\"command\"\u003eSET ROLE\u003c/code\u003e \u003cem class=\"replaceable\"\u003e\u003ccode\u003erolename\u003c/code\u003e\u003c/em\u003e command after connecting to the database. It is useful when the authenticated user (specified by \u003ccode class=\"option\"\u003e-U\u003c/code\u003e) lacks privileges needed by \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, 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.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\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\n\u003cdd\u003e\n\u003cp\u003eDefault connection parameters\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, also uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (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 \u003ccode class=\"envar\"\u003ePGDATABASE\u003c/code\u003e when a database name is not supplied.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-DIAGNOSTICS\"\u003e\n\u003ch2\u003eDiagnostics\u003c/h2\u003e\n\u003cp\u003eWhen a direct database connection is specified using the \u003ccode class=\"option\"\u003e-d\u003c/code\u003e option, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e internally executes SQL statements. If you have problems running \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e, make sure you are able to select information from the database using, for 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 settings and environment variables used by the \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e front-end library will apply.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-NOTES\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eIf your installation has any local additions to the \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e database, be careful to load the output of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e into a truly empty database; otherwise you are likely to get errors due to duplicate definitions of the added objects. To make an empty database without any local additions, copy from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, for example:\u003c/p\u003e\n\u003cpre class=\"programlisting\"\u003eCREATE DATABASE foo WITH TEMPLATE template0;\n\u003c/pre\u003e\n\u003cp\u003eThe limitations of \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e are detailed below.\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eWhen restoring data to a pre-existing table and the option \u003ccode class=\"option\"\u003e--disable-triggers\u003c/code\u003e is used, \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e emits commands to disable triggers on user tables before inserting the data, then emits commands to re-enable them after the data has been inserted. If the restore is stopped in the middle, the system catalogs might be left in the wrong state.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e cannot restore large objects selectively; for instance, only those for a specific table. If an archive contains large objects, then all large objects will be restored, or none of them if they are excluded via \u003ccode class=\"option\"\u003e-L\u003c/code\u003e, \u003ccode class=\"option\"\u003e-t\u003c/code\u003e, or other options.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eSee 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 limitations of \u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003epg_restore\u003c/code\u003e will restore optimizer statistics if included in the dump file. If not all statistics were restored, it may be useful to run \u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e on each restored table so the 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 information.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"APP-PGRESTORE-EXAMPLES\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eAssume we have dumped a database called \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e into a custom-format dump file:\u003c/p\u003e\n\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\n\u003cp\u003eTo drop the database and recreate it from the dump:\u003c/p\u003e\n\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\n\u003cp\u003eThe database named in the \u003ccode class=\"option\"\u003e-d\u003c/code\u003e switch can be any database existing in the cluster; \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e only uses it to issue the \u003ccode class=\"command\"\u003eCREATE DATABASE\u003c/code\u003e command for \u003ccode class=\"literal\"\u003emydb\u003c/code\u003e. With \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, data is always restored into the database name that appears in the dump file.\u003c/p\u003e\n\u003cp\u003eTo restore the dump into a new database called \u003ccode class=\"literal\"\u003enewdb\u003c/code\u003e:\u003c/p\u003e\n\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\n\u003cp\u003eNotice we don't use \u003ccode class=\"option\"\u003e-C\u003c/code\u003e, and instead connect directly to the database to be restored into. Also note that we clone the new database from \u003ccode class=\"literal\"\u003etemplate0\u003c/code\u003e not \u003ccode class=\"literal\"\u003etemplate1\u003c/code\u003e, to ensure it is initially empty.\u003c/p\u003e\n\u003cp\u003eTo reorder database items, it is first necessary to dump the table of contents of the archive:\u003c/p\u003e\n\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\n\u003cp\u003eThe listing file consists of a header and one line for each item, e.g.:\u003c/p\u003e\n\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\n\u003cp\u003eSemicolons start a comment, and the numbers at the start of lines refer to the internal archive ID assigned to each item.\u003c/p\u003e\n\u003cp\u003eLines in the file can be commented out, deleted, and reordered. For example:\u003c/p\u003e\n\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\n\u003cp\u003ecould be used as input to \u003cspan class=\"application\"\u003epg_restore\u003c/span\u003e and would only restore items 10 and 6, in that order:\u003c/p\u003e\n\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\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.19.11\"\u003e\n\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\n\u003c/div\u003e\n\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":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
