{"kind": "tool", "major": "18", "item": {"slug": "pg-dump", "name": "pg_dump", "name_zh": "", "category": "Client applications", "summary": "pg_dump \u2014 export a PostgreSQL database as an SQL script or to other formats", "aliases": ["pg_dump"], "content_hash": "c2dd35a94adb46b5c132ee33391b6b068e814d594cc6847dce93b76cf632698b", "versions": {"10": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "10.23"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "52"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-b --blobs"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-B --no-blobs"}}, {"summary": "Output commands to clean (drop) database objects prior to outputting the commands for creating them. (Unless --if-exists is also specified, restore might generate some harmless error messages, if any objects were not present in the destination database.)", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-C --create"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-n schema --schema= schema"}}, {"summary": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-N schema --exclude-schema= schema"}}, {"summary": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-o --oids"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-t table --table= table"}}, {"summary": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-T table --exclude-table= table"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-Z 0..9 --compress= 0..9"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include commands to temporarily disable triggers on the target tables while the data is reloaded. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data reload.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--exclude-table-data= table"}}, {"summary": "Use conditional commands (i.e., add an IF EXISTS clause) when cleaning database objects. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--inserts"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--no-sync"}}, {"summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--no-synchronized-snapshots"}}, {"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": {"url": "/docs/10/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details).", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--strict-names"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/10/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/10/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/10/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/10/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/10/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --blobs", "source_url": "/docs/10/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-blobs", "source_url": "/docs/10/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to clean (drop) database objects prior to outputting the commands for creating them. (Unless --if-exists is also specified, restore might generate some harmless error messages, if any objects were not present in the destination database.)", "signature": "-c --clean", "source_url": "/docs/10/app-pgdump.html", "description": "Output commands to clean (drop) database objects prior to outputting the commands for creating them. (Unless --if-exists is also specified, restore might generate some harmless error messages, if any objects were not present in the destination database.) This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/10/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/10/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/10/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/10/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/10/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n schema", "--schema= schema"], "summary": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": "-n schema --schema= schema", "source_url": "/docs/10/app-pgdump.html", "description": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N schema", "--exclude-schema= schema"], "summary": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N schema --exclude-schema= schema", "source_url": "/docs/10/app-pgdump.html", "description": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-o", "--oids"], "summary": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used.", "signature": "-o --oids", "source_url": "/docs/10/app-pgdump.html", "description": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/10/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/10/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/10/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/10/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t table", "--table= table"], "summary": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": "-t table --table= table", "source_url": "/docs/10/app-pgdump.html", "description": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T table", "--exclude-table= table"], "summary": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T table --exclude-table= table", "source_url": "/docs/10/app-pgdump.html", "description": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": "-v --verbose", "source_url": "/docs/10/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/10/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/10/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": "-Z 0..9 --compress= 0..9", "source_url": "/docs/10/app-pgdump.html", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/10/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/10/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/10/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include commands to temporarily disable triggers on the target tables while the data is reloaded. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data reload.", "signature": "--disable-triggers", "source_url": "/docs/10/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include commands to temporarily disable triggers on the target tables while the data is reloaded. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data reload. Presently, the commands emitted for --disable-triggers must be done as superuser. So, you should also specify a superuser name with -S , or preferably be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/10/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= table"], "summary": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= table", "source_url": "/docs/10/app-pgdump.html", "description": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--if-exists"], "summary": "Use conditional commands (i.e., add an IF EXISTS clause) when cleaning database objects. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/10/app-pgdump.html", "description": "Use conditional commands (i.e., add an IF EXISTS clause) when cleaning database objects. This option is not valid unless --clean is also specified."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/10/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/10/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/10/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/10/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/10/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/10/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": "--no-synchronized-snapshots", "source_url": "/docs/10/app-pgdump.html", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/10/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/10/app-pgdump.html", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/10/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/10/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/10/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/10/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 48 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/10/app-pgdump.html", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/10/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/10/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/10/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/10/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/10/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/10/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/10/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/10/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/10/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=10", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "label": "10.23", "major": "10", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/10/postgresql-10-A4.pdf", "bytes": 12631706, "pages": 2591, "sha256": "34497ab9efb45c5bdf1bd11b9016b5451354feb462fa029cf74557a5fa5fbbc1", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/10/postgresql-10-US.pdf", "bytes": 12531684, "pages": 2724, "sha256": "429cc7133ddf4f97c560aa466dc9caea4b718721a8321e293357037cf0af4733", "built_at": "2026-09-26"}}, "tree": "10", "index": "index.html", "major": "10", "pages": 1085, "release": "10.23", "source_url": "https://ftp.postgresql.org/pub/source/v10.23/postgresql-10.23.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "revision": "f9301feba91e2e2566038a36b8cee0e4402db68989538f88670fddd20b1f78ea", "evidence_kind": "English manual and source declarations", "source_sha256": "94a4b2528372458e5662c18d406629266667c437198160a18cdfd2c4a4d6eee9"}, "sources": [{"url": "/docs/10/app-pgdump.html", "file": "app-pgdump.html", "label": "10.23 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "fa478b210ceee675ec1a08a237e597d597b72b8dfde9dfe4e612005c333e6a9a"}, {"url": "/docs/10/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "e4330732b6acd6c025a1fbdce45574b23d964de847a1b849ea88b98ab628d2e2"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\">pg_dump</span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.12.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To backup global objects that are common to all databases in a cluster, such as roles and tablespaces, use <a class=\"xref\" href=\"/docs/10/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/10/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/10/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code></span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code></span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to clean (drop) database objects prior to outputting the commands for creating them. (Unless <code class=\"option\">--if-exists</code> is also specified, restore might generate some harmless error messages, if any objects were not present in the destination database.)</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span> tool. This format is compressed by default and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/10/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n<p>If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the <code class=\"option\">--no-synchronized-snapshots</code> parameter when running <code class=\"command\">pg_dump -j</code> against a pre-9.2 <span class=\"productname\">PostgreSQL</span> server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>schema</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>schema</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>schema</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. Also, the <em class=\"replaceable\"><code>schema</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/10/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/10/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as blobs are not dumped when <code class=\"option\">-n</code> is specified. You can add blobs back to the dump with the <code class=\"option\">--blobs</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>schema</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>schema</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching the <em class=\"replaceable\"><code>schema</code></em> pattern. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code><br></span><span class=\"term\"><code class=\"option\">--oids</code></span></dt>\n<dd>\n<p>Dump object identifiers (OIDs) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>table</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>table</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>table</code></em>. For this purpose, <span class=\"quote\">\u201c<span class=\"quote\">table</span>\u201d</span> includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. Also, the <em class=\"replaceable\"><code>table</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/10/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/10/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>The behavior of the <code class=\"option\">-t</code> switch is not entirely upward compatible with pre-8.2 <span class=\"productname\">PostgreSQL</span> versions. Formerly, writing <code class=\"literal\">-t tab</code> would dump all tables named <code class=\"literal\">tab</code>, but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write <code class=\"literal\">-t '*.tab'</code>. Also, you must write something like <code class=\"literal\">-t sch.tab</code> to select a table in a particular schema, rather than the old locution of <code class=\"literal\">-n sch -t tab</code>.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>table</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>table</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching the <em class=\"replaceable\"><code>table</code></em> pattern. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>0..9</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>0..9</code></em></code></span></dt>\n<dd>\n<p>Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>; but the default is not to compress. The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include commands to temporarily disable triggers on the target tables while the data is reloaded. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data reload.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/10/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/10/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>table</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching the <em class=\"replaceable\"><code>table</code></em> pattern. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use conditional commands (i.e., add an <code class=\"literal\">IF EXISTS</code> clause) when cleaning database objects. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-synchronized-snapshots</code></span></dt>\n<dd>\n<p>This option allows running <code class=\"command\">pg_dump -j</code> against a pre-9.2 server, see the documentation of the <code class=\"option\">-j</code> parameter for more details.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/10/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/10/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.82.\u00a0Snapshot Synchronization Functions\">Table\u00a09.82</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/10/logicaldecoding.html\" title=\"Chapter\u00a048.\u00a0Logical Decoding\">Chapter\u00a048</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/10/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"33.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/10/libpq-envars.html\" title=\"33.14.\u00a0Environment Variables\">Section\u00a033.14</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/10/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the statistics collector. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/10/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/10/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information. The dump file also does not contain any <code class=\"command\">ALTER DATABASE ... SET</code> commands; these settings are dumped by <a class=\"xref\" href=\"/docs/10/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, along with database users and other installation-wide settings.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 8.0 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into a SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/10/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre></div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.11\">\n<h2>See Also</h2>\n<span class=\"simplelist\"><a class=\"xref\" href=\"/docs/10/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/10/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a>, <a class=\"xref\" href=\"/docs/10/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span></div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "signature": "-b --blobs", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "signature": "-B --no-blobs", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to clean (drop) database objects prior to outputting the commands for creating them. (Unless --if-exists is also specified, restore might generate some harmless error messages, if any objects were not present in the destination database.) This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n schema", "--schema= schema"], "signature": "-n schema --schema= schema", "description": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N schema", "--exclude-schema= schema"], "signature": "-N schema --exclude-schema= schema", "description": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-o", "--oids"], "signature": "-o --oids", "description": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t table", "--table= table"], "signature": "-t table --table= table", "description": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T table", "--exclude-table= table"], "signature": "-T table --exclude-table= table", "description": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "signature": "-Z 0..9 --compress= 0..9", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include commands to temporarily disable triggers on the target tables while the data is reloaded. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data reload. Presently, the commands emitted for --disable-triggers must be done as superuser. So, you should also specify a superuser name with -S , or preferably be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= table"], "signature": "--exclude-table-data= table", "description": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use conditional commands (i.e., add an IF EXISTS clause) when cleaning database objects. This option is not valid unless --clean is also specified."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in reloading a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "signature": "--no-synchronized-snapshots", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 48 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}]}, "comparison_hash": "d4971e4d5e4a2373701d1ca29b9fb89686a74e843d410aaf8efced28fda2ec30"}, "11": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "11.22"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "54"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-b --blobs"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-B --no-blobs"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-C --create"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-n schema --schema= schema"}}, {"summary": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-N schema --exclude-schema= schema"}}, {"summary": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-o --oids"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-t table --table= table"}}, {"summary": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-T table --exclude-table= table"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-Z 0..9 --compress= 0..9"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": {"url": "/docs/11/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--exclude-table-data= table"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump comments.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--no-sync"}}, {"summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--no-synchronized-snapshots"}}, {"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": {"url": "/docs/11/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details).", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--strict-names"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/11/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/11/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/11/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/11/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/11/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --blobs", "source_url": "/docs/11/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-blobs", "source_url": "/docs/11/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/11/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/11/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/11/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/11/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/11/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/11/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n schema", "--schema= schema"], "summary": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": "-n schema --schema= schema", "source_url": "/docs/11/app-pgdump.html", "description": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N schema", "--exclude-schema= schema"], "summary": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N schema --exclude-schema= schema", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-o", "--oids"], "summary": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used.", "signature": "-o --oids", "source_url": "/docs/11/app-pgdump.html", "description": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/11/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/11/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/11/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/11/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t table", "--table= table"], "summary": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": "-t table --table= table", "source_url": "/docs/11/app-pgdump.html", "description": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T table", "--exclude-table= table"], "summary": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T table --exclude-table= table", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": "-v --verbose", "source_url": "/docs/11/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/11/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/11/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": "-Z 0..9 --compress= 0..9", "source_url": "/docs/11/app-pgdump.html", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/11/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/11/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/11/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/11/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/11/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= table"], "summary": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= table", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/11/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/11/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/11/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/11/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump comments.", "signature": "--no-comments", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump comments."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/11/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": "--no-synchronized-snapshots", "source_url": "/docs/11/app-pgdump.html", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/11/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/11/app-pgdump.html", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/11/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/11/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/11/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/11/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/11/app-pgdump.html", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/11/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/11/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/11/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/11/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/11/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/11/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/11/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/11/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/11/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=11", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "label": "11.22", "major": "11", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/11/postgresql-11-A4.pdf", "bytes": 13057499, "pages": 2732, "sha256": "41d75855e610d0d9b8802b87dc5b080bef8d7e91c7cf69401fbf8d3cf801b4b5", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/11/postgresql-11-US.pdf", "bytes": 12961189, "pages": 2883, "sha256": "6a8899ef36935a5b7ed2b436207564a567a4ef1eb1c2200195876b8de4d4fa30", "built_at": "2026-09-26"}}, "tree": "11", "index": "index.html", "major": "11", "pages": 1125, "release": "11.22", "source_url": "https://ftp.postgresql.org/pub/source/v11.22/postgresql-11.22.tar.bz2", "svg_assets": 0, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "revision": "53315ddaf3b3f9e6669fd1edc096bbb2cd4a65ea3e836c89e542b43af9ba3a7f", "evidence_kind": "English manual and source declarations", "source_sha256": "2cb7c97d7a0d7278851bbc9c61f467b69c094c72b81740b751108e7892ebe1f0"}, "sources": [{"url": "/docs/11/app-pgdump.html", "file": "app-pgdump.html", "label": "11.22 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "89e75cd7cd3fa712860d671625758ec0fed13f80603cbfb70cb661a6f8bd4889"}, {"url": "/docs/11/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "3a30e696058b118a55cc42892c39671d9bae86f77e1024d5ebcc4688ad9ab4c3"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\">pg_dump</span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.12.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/11/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/11/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/11/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code></span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code></span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span> tool. This format is compressed by default and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/11/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n<p>If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the <code class=\"option\">--no-synchronized-snapshots</code> parameter when running <code class=\"command\">pg_dump -j</code> against a pre-9.2 <span class=\"productname\">PostgreSQL</span> server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>schema</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>schema</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>schema</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. Also, the <em class=\"replaceable\"><code>schema</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/11/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/11/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as blobs are not dumped when <code class=\"option\">-n</code> is specified. You can add blobs back to the dump with the <code class=\"option\">--blobs</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>schema</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>schema</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching the <em class=\"replaceable\"><code>schema</code></em> pattern. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-o</code><br></span><span class=\"term\"><code class=\"option\">--oids</code></span></dt>\n<dd>\n<p>Dump object identifiers (OIDs) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>table</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>table</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>table</code></em>. For this purpose, <span class=\"quote\">\u201c<span class=\"quote\">table</span>\u201d</span> includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. Also, the <em class=\"replaceable\"><code>table</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/11/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/11/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>The behavior of the <code class=\"option\">-t</code> switch is not entirely upward compatible with pre-8.2 <span class=\"productname\">PostgreSQL</span> versions. Formerly, writing <code class=\"literal\">-t tab</code> would dump all tables named <code class=\"literal\">tab</code>, but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write <code class=\"literal\">-t '*.tab'</code>. Also, you must write something like <code class=\"literal\">-t sch.tab</code> to select a table in a particular schema, rather than the old locution of <code class=\"literal\">-n sch -t tab</code>.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>table</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>table</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching the <em class=\"replaceable\"><code>table</code></em> pattern. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>0..9</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>0..9</code></em></code></span></dt>\n<dd>\n<p>Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>; but the default is not to compress. The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/11/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/11/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>table</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching the <em class=\"replaceable\"><code>table</code></em> pattern. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump comments.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-synchronized-snapshots</code></span></dt>\n<dd>\n<p>This option allows running <code class=\"command\">pg_dump -j</code> against a pre-9.2 server, see the documentation of the <code class=\"option\">-j</code> parameter for more details.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/11/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/11/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.82.\u00a0Snapshot Synchronization Functions\">Table\u00a09.82</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/11/logicaldecoding.html\" title=\"Chapter\u00a049.\u00a0Logical Decoding\">Chapter\u00a049</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/11/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"34.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/11/libpq-envars.html\" title=\"34.14.\u00a0Environment Variables\">Section\u00a034.14</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/11/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the statistics collector. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/11/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/11/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 8.0 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into a SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/11/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/11/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/11/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a>, <a class=\"xref\" href=\"/docs/11/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "signature": "-b --blobs", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "signature": "-B --no-blobs", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n schema", "--schema= schema"], "signature": "-n schema --schema= schema", "description": "Dump only schemas matching schema ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. Also, the schema parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N schema", "--exclude-schema= schema"], "signature": "-N schema --exclude-schema= schema", "description": "Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-o", "--oids"], "signature": "-o --oids", "description": "Dump object identifiers ( OID s) as part of the data for every table. Use this option if your application references the OID columns in some way (e.g., in a foreign key constraint). Otherwise, this option should not be used."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t table", "--table= table"], "signature": "-t table --table= table", "description": "Dump only tables with names matching table . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. Also, the table parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T table", "--exclude-table= table"], "signature": "-T table --exclude-table= table", "description": "Do not dump any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "signature": "-Z 0..9 --compress= 0..9", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= table"], "signature": "--exclude-table-data= table", "description": "Do not dump data for any tables matching the table pattern. The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. However, since this option generates a separate command for each row, an error in restoring a row causes only that row to be lost rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump comments."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "signature": "--no-synchronized-snapshots", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.82 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}]}, "comparison_hash": "355fc617da5a629d99646a3a0f1a55309f2517b6dff7569721372cfe44925efa"}, "12": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "12.22"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "56"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-b --blobs"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-B --no-blobs"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-C --create"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-Z 0..9 --compress= 0..9"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": {"url": "/docs/12/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump comments.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--no-sync"}}, {"summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--no-synchronized-snapshots"}}, {"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": {"url": "/docs/12/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.87 for more details).", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--strict-names"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/12/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/12/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/12/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/12/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/12/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --blobs", "source_url": "/docs/12/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-blobs", "source_url": "/docs/12/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/12/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/12/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/12/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/12/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/12/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/12/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": "-n pattern --schema= pattern", "source_url": "/docs/12/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/12/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/12/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/12/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/12/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples .", "signature": "-t pattern --table= pattern", "source_url": "/docs/12/app-pgdump.html", "description": "Dump only tables with names matching pattern . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": "-v --verbose", "source_url": "/docs/12/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/12/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/12/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": "-Z 0..9 --compress= 0..9", "source_url": "/docs/12/app-pgdump.html", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/12/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/12/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/12/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/12/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/12/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/12/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/12/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/12/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/12/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/12/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump comments.", "signature": "--no-comments", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump comments."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/12/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": "--no-synchronized-snapshots", "source_url": "/docs/12/app-pgdump.html", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/12/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/12/app-pgdump.html", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/12/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/12/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/12/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/12/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/12/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.87 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/12/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.87 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 48 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/12/app-pgdump.html", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/12/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/12/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/12/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/12/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/12/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/12/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/12/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/12/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/12/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=12", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "label": "12.22", "major": "12", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/12/postgresql-12-A4.pdf", "bytes": 13424351, "pages": 2803, "sha256": "7422cf53fd1939e7a3d2925231a88b0330e468afa5393627cac0ff86158a0621", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/12/postgresql-12-US.pdf", "bytes": 13322565, "pages": 2958, "sha256": "51f3b04e72907fc38512685946223452ea65f84419c60c66241dfa3396035e77", "built_at": "2026-09-26"}}, "tree": "12", "index": "index.html", "major": "12", "pages": 1131, "release": "12.22", "source_url": "https://ftp.postgresql.org/pub/source/v12.22/postgresql-12.22.tar.bz2", "svg_assets": 2, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "revision": "7a827e97cbfacd7febff75f34443e2043e40723de5b6d8c9d81a9430b65a37e4", "evidence_kind": "English manual and source declarations", "source_sha256": "8df3c0474782589d3c6f374b5133b1bd14d168086edbc13c6e72e67dd4527a3b"}, "sources": [{"url": "/docs/12/app-pgdump.html", "file": "app-pgdump.html", "label": "12.22 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "1696b371ad74d181dc249929d2331d2f8ba5a201a6a6dd6544aae7dc85e1c2f1"}, {"url": "/docs/12/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "089624dd131f52eea682b304f87a1acb03392ee7bcf78b000699c9b17c7ca22d"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\">pg_dump</span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.12.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/12/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/12/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/12/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code></span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code></span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span> tool. This format is compressed by default and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/12/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n<p>If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the <code class=\"option\">--no-synchronized-snapshots</code> parameter when running <code class=\"command\">pg_dump -j</code> against a pre-9.2 <span class=\"productname\">PostgreSQL</span> server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/12/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/12/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as blobs are not dumped when <code class=\"option\">-n</code> is specified. You can add blobs back to the dump with the <code class=\"option\">--blobs</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. For this purpose, <span class=\"quote\">\u201c<span class=\"quote\">table</span>\u201d</span> includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/12/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/12/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>The behavior of the <code class=\"option\">-t</code> switch is not entirely upward compatible with pre-8.2 <span class=\"productname\">PostgreSQL</span> versions. Formerly, writing <code class=\"literal\">-t tab</code> would dump all tables named <code class=\"literal\">tab</code>, but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write <code class=\"literal\">-t '*.tab'</code>. Also, you must write something like <code class=\"literal\">-t sch.tab</code> to select a table in a particular schema, rather than the old locution of <code class=\"literal\">-n sch -t tab</code>.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>0..9</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>0..9</code></em></code></span></dt>\n<dd>\n<p>Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>; but the default is not to compress. The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/12/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/12/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump comments.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-synchronized-snapshots</code></span></dt>\n<dd>\n<p>This option allows running <code class=\"command\">pg_dump -j</code> against a pre-9.2 server, see the documentation of the <code class=\"option\">-j</code> parameter for more details.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/12/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/12/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.87.\u00a0Snapshot Synchronization Functions\">Table\u00a09.87</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/12/logicaldecoding.html\" title=\"Chapter\u00a048.\u00a0Logical Decoding\">Chapter\u00a048</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/12/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"33.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/12/libpq-envars.html\" title=\"33.14.\u00a0Environment Variables\">Section\u00a033.14</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/12/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the statistics collector. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/12/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/12/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 8.0 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into a SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/12/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/12/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/12/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a>, <a class=\"xref\" href=\"/docs/12/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "signature": "-b --blobs", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "signature": "-B --no-blobs", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option reduces the time of the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . For this purpose, \u201c table \u201d includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "signature": "-Z 0..9 --compress= 0..9", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump comments."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "signature": "--no-synchronized-snapshots", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.87 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 48 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "dd96f8017b548a3f104bce2b0d469d93100b593a7aa8bc25185ccf203007b07b"}, "13": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "13.23"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "58"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-b --blobs"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-B --no-blobs"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-C --create"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-Z 0..9 --compress= 0..9"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": {"url": "/docs/13/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump comments.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--no-sync"}}, {"summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--no-synchronized-snapshots"}}, {"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": {"url": "/docs/13/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.88 for more details).", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--strict-names"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/13/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/13/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/13/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/13/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/13/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --blobs", "source_url": "/docs/13/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-blobs", "source_url": "/docs/13/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/13/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/13/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/13/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/13/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/13/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/13/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/13/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/13/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/13/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/13/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/13/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/13/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.", "signature": "-v --verbose", "source_url": "/docs/13/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/13/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/13/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": "-Z 0..9 --compress= 0..9", "source_url": "/docs/13/app-pgdump.html", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/13/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/13/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/13/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/13/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/13/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/13/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/13/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/13/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/13/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/13/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/13/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump comments.", "signature": "--no-comments", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump comments."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/13/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": "--no-synchronized-snapshots", "source_url": "/docs/13/app-pgdump.html", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/13/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/13/app-pgdump.html", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/13/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/13/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/13/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/13/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/13/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/13/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.88 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/13/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.88 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 48 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/13/app-pgdump.html", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/13/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/13/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/13/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/13/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/13/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/13/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/13/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/13/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/13/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=13", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "label": "13.23", "major": "13", "channel": "historical", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/13/postgresql-13-A4.pdf", "bytes": 13843239, "pages": 2826, "sha256": "171cc09f90936dbc1cbd503a98ff07ae72ea58ab9771ff051313f1217737799c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/13/postgresql-13-US.pdf", "bytes": 13739572, "pages": 2984, "sha256": "48d09c6e197d9db4220f41afe83efe848a8661b1b168d3b89419751ecaf6c24d", "built_at": "2026-09-26"}}, "tree": "13", "index": "index.html", "major": "13", "pages": 1139, "release": "13.23", "source_url": "https://ftp.postgresql.org/pub/source/v13.23/postgresql-13.23.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "revision": "614ee3133270254e476c118cdf6f72af78d4e4b8bbd9b28ed9ab1e14e4e9c0f6", "evidence_kind": "English manual and source declarations", "source_sha256": "6ec3c82726af92b7dec873fa1cdf881eca92a4219787dfad05acb6b10e041fd6"}, "sources": [{"url": "/docs/13/app-pgdump.html", "file": "app-pgdump.html", "label": "13.23 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "5f49d3ad076ce3e43e4006c066836f8f794a4b0b0d3c5751373143e4233bfa43"}, {"url": "/docs/13/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "2a16c2982d9803edd4bd6920f76b66083e7f2959182d6a3bcec7ccfbac0a9ad8"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\">pg_dump</span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.12.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/13/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/13/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/13/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code></span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code></span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span> tool. This format is compressed by default and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/13/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n<p>If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the <code class=\"option\">--no-synchronized-snapshots</code> parameter when running <code class=\"command\">pg_dump -j</code> against a pre-9.2 <span class=\"productname\">PostgreSQL</span> server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/13/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/13/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as blobs are not dumped when <code class=\"option\">-n</code> is specified. You can add blobs back to the dump with the <code class=\"option\">--blobs</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/13/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/13/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>The behavior of the <code class=\"option\">-t</code> switch is not entirely upward compatible with pre-8.2 <span class=\"productname\">PostgreSQL</span> versions. Formerly, writing <code class=\"literal\">-t tab</code> would dump all tables named <code class=\"literal\">tab</code>, but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write <code class=\"literal\">-t '*.tab'</code>. Also, you must write something like <code class=\"literal\">-t sch.tab</code> to select a table in a particular schema, rather than the old locution of <code class=\"literal\">-n sch -t tab</code>.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>0..9</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>0..9</code></em></code></span></dt>\n<dd>\n<p>Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>; but the default is not to compress. The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/13/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/13/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/13/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/13/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump comments.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-synchronized-snapshots</code></span></dt>\n<dd>\n<p>This option allows running <code class=\"command\">pg_dump -j</code> against a pre-9.2 server, see the documentation of the <code class=\"option\">-j</code> parameter for more details.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/13/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/13/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.88.\u00a0Snapshot Synchronization Functions\">Table\u00a09.88</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/13/logicaldecoding.html\" title=\"Chapter\u00a048.\u00a0Logical Decoding\">Chapter\u00a048</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/13/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"33.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/13/libpq-envars.html\" title=\"33.14.\u00a0Environment Variables\">Section\u00a033.14</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/13/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the statistics collector. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/13/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/13/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 8.0 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into a SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/13/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.12.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/13/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/13/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\">pg_restore</span></a>, <a class=\"xref\" href=\"/docs/13/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "signature": "-b --blobs", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "signature": "-B --no-blobs", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.)"}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump master process requests shared locks on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the master process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the master process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the master connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database. Note The behavior of the -t switch is not entirely upward compatible with pre-8.2 PostgreSQL versions. Formerly, writing -t tab would dump all tables named tab , but now it just dumps whichever one is visible in your default search path. To get the old behavior you can write -t '*.tab' . Also, you must write something like -t sch.tab to select a table in a particular schema, rather than the old locution of -n sch -t tab ."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "signature": "-Z 0..9 --compress= 0..9", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump comments."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "signature": "--no-synchronized-snapshots", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.88 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 48 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one schema/table in the database to be dumped. Note that if none of the schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "8704d768bea5e042661f4f5d82baad8afb446bb4b89f6c0828d15bf974ed25e7"}, "14": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "14.24"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "60"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-b --blobs"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-B --no-blobs"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 .", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-Z 0..9 --compress= 0..9"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": {"url": "/docs/14/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump comments.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-sync"}}, {"summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-synchronized-snapshots"}}, {"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": {"url": "/docs/14/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.90 for more details).", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--strict-names"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/14/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/14/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/14/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/14/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/14/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --blobs", "source_url": "/docs/14/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-blobs", "source_url": "/docs/14/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/14/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/14/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/14/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/14/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/14/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/14/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/14/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the leader connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/14/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/14/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/14/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/14/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/14/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/14/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/14/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/14/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/14/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": "-Z 0..9 --compress= 0..9", "source_url": "/docs/14/app-pgdump.html", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/14/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/14/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/14/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/14/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/14/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/14/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/14/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/14/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/14/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/14/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/14/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump comments.", "signature": "--no-comments", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump comments."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/14/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "summary": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details.", "signature": "--no-synchronized-snapshots", "source_url": "/docs/14/app-pgdump.html", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/14/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/14/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/14/app-pgdump.html", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/14/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/14/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/14/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/14/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/14/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/14/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.90 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/14/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.90 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/14/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/14/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/14/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/14/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/14/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/14/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/14/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/14/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/14/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/14/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=14", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "label": "14.24", "major": "14", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/14/postgresql-14-A4.pdf", "bytes": 14354704, "pages": 2944, "sha256": "8bc6b9dd7b246888bb77f0a5e8c39a2eae52e9926569832669c7d1600becb27c", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/14/postgresql-14-US.pdf", "bytes": 14242178, "pages": 3102, "sha256": "b7ecb5a5f62d8b9f73a69e25a7d26ba285373bc53168a553bff7b77955506db4", "built_at": "2026-09-26"}}, "tree": "14", "index": "index.html", "major": "14", "pages": 1158, "release": "14.24", "source_url": "https://ftp.postgresql.org/pub/source/v14.24/postgresql-14.24.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "revision": "588700d46356d8837c77c7c0a4e71e645fe6535983b8f1830aa8f2e4e41c40ae", "evidence_kind": "English manual and source declarations", "source_sha256": "a7fa7ed3d558172355f51406097a7bd4f6b473be80f311ef7cda96bf383d8897"}, "sources": [{"url": "/docs/14/app-pgdump.html", "file": "app-pgdump.html", "label": "14.24 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "3f03c57d602decd44b16a5c47cd6e85f9fa855c4f29b8e27316d0d525d1aef1c"}, {"url": "/docs/14/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "5a13567a052954dfe494dfaab9f50919faa1ae56023930fdbb78d45e53feccde"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.13.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/14/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/14/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/14/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code></span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code></span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/14/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-e</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/14/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"24.3.1.\u00a0Supported Character Sets\">Section\u00a024.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span> tool. This format is compressed by default and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/14/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/14/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n<p>If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the leader connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the <code class=\"option\">--no-synchronized-snapshots</code> parameter when running <code class=\"command\">pg_dump -j</code> against a pre-9.2 <span class=\"productname\">PostgreSQL</span> server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/14/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/14/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as blobs are not dumped when <code class=\"option\">-n</code> is specified. You can add blobs back to the dump with the <code class=\"option\">--blobs</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/14/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/14/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>0..9</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>0..9</code></em></code></span></dt>\n<dd>\n<p>Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>; but the default is not to compress. The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/14/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/14/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/14/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/14/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump comments.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-synchronized-snapshots</code></span></dt>\n<dd>\n<p>This option allows running <code class=\"command\">pg_dump -j</code> against a pre-9.2 server, see the documentation of the <code class=\"option\">-j</code> parameter for more details.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/14/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/14/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.90.\u00a0Snapshot Synchronization Functions\">Table\u00a09.90</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/14/logicaldecoding.html\" title=\"Chapter\u00a049.\u00a0Logical Decoding\">Chapter\u00a049</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/14/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"34.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.13.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/14/libpq-envars.html\" title=\"34.15.\u00a0Environment Variables\">Section\u00a034.15</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/14/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the statistics collector. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/14/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"25.1.3.\u00a0Updating Planner Statistics\">Section\u00a025.1.3</a> and <a class=\"xref\" href=\"/docs/14/routine-vacuuming.html#AUTOVACUUM\" title=\"25.1.6.\u00a0The Autovacuum Daemon\">Section\u00a025.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 8.0 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/14/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.13.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/14/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/14/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/14/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "signature": "-b --blobs", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "signature": "-B --no-blobs", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. For a consistent backup, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need to make sure that the database content doesn't change from between the time the leader connects to the database until the last worker job has connected to the database. The easiest way to do this is to halt any data modifying processes (DDL and DML) accessing the database before starting the backup. You also need to specify the --no-synchronized-snapshots parameter when running pg_dump -j against a pre-9.2 PostgreSQL server."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "signature": "-Z 0..9 --compress= 0..9", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump comments."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-synchronized-snapshots"], "signature": "--no-synchronized-snapshots", "description": "This option allows running pg_dump -j against a pre-9.2 server, see the documentation of the -j parameter for more details."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables. This option has no effect on whether or not the table definitions (schema) are dumped; it only suppresses dumping the table data. Data in unlogged tables is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.90 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "45402b861aabadbe6c7d717cb48ba9e56b8f45fdfe79a138e52d5ad874572045"}, "15": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "15.19"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "60"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-b --blobs"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-B --no-blobs"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 .", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-Z 0..9 --compress= 0..9"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": {"url": "/docs/15/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump comments.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--no-sync"}}, {"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": {"url": "/docs/15/app-pgdump.html", "text": "--no-table-access-method"}}, {"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": {"url": "/docs/15/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.92 for more details).", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--strict-names"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/15/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/15/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/15/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/15/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/15/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --blobs", "source_url": "/docs/15/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-blobs", "source_url": "/docs/15/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/15/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/15/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/15/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/15/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/15/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/15/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/15/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/15/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/15/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/15/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/15/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/15/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/15/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/15/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/15/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/15/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "summary": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all.", "signature": "-Z 0..9 --compress= 0..9", "source_url": "/docs/15/app-pgdump.html", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/15/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/15/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/15/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/15/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/15/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/15/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/15/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/15/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/15/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/15/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/15/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump comments.", "signature": "--no-comments", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump comments."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/15/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "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": "--no-table-access-method", "source_url": "/docs/15/app-pgdump.html", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/15/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/15/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/15/app-pgdump.html", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/15/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/15/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/15/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/15/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/15/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/15/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.92 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/15/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.92 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/15/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/15/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/15/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/15/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/15/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/15/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/15/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/15/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/15/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/15/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=15", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "label": "15.19", "major": "15", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/15/postgresql-15-A4.pdf", "bytes": 14609140, "pages": 2987, "sha256": "66228564a4d16efb47d6a914085716ecfe22ca1566db56bc7c3d82f790646d72", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/15/postgresql-15-US.pdf", "bytes": 14495690, "pages": 3153, "sha256": "645a498c2390d47a6223ec74770631185807a19c484edb0fc5a295d9f460bc02", "built_at": "2026-09-26"}}, "tree": "15", "index": "index.html", "major": "15", "pages": 1168, "release": "15.19", "source_url": "https://ftp.postgresql.org/pub/source/v15.19/postgresql-15.19.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "revision": "6af958c6520151fc7697d56e0616b03fb00522c4568158674d452ae0644ba545", "evidence_kind": "English manual and source declarations", "source_sha256": "e1a64a87a46b825b88c082e4518161a47aab53c45694964f8ba1df28f7859f89"}, "sources": [{"url": "/docs/15/app-pgdump.html", "file": "app-pgdump.html", "label": "15.19 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "682e561faf72da2e4719707ed56c534bca0cbe42d737f7cb9753e59d43be70d4"}, {"url": "/docs/15/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "015b2ea2bd205946a55a1b837e735570631bac831c92074a6bf58444f9a3cb98"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.13.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/15/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/15/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/15/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code></span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code></span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/15/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-e</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/15/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"24.3.1.\u00a0Supported Character Sets\">Section\u00a024.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span> tool. This format is compressed by default and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/15/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/15/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/15/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/15/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as blobs are not dumped when <code class=\"option\">-n</code> is specified. You can add blobs back to the dump with the <code class=\"option\">--blobs</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/15/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/15/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>0..9</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>0..9</code></em></code></span></dt>\n<dd>\n<p>Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>; but the default is not to compress. The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/15/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/15/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/15/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/15/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump comments.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-table-access-method</code></span></dt>\n<dd>\n<p>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.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/15/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/15/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.92.\u00a0Snapshot Synchronization Functions\">Table\u00a09.92</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/15/logicaldecoding.html\" title=\"Chapter\u00a049.\u00a0Logical Decoding\">Chapter\u00a049</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/15/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"34.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.13.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/15/libpq-envars.html\" title=\"34.15.\u00a0Environment Variables\">Section\u00a034.15</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/15/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the cumulative statistics system. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/15/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"25.1.3.\u00a0Updating Planner Statistics\">Section\u00a025.1.3</a> and <a class=\"xref\" href=\"/docs/15/routine-vacuuming.html#AUTOVACUUM\" title=\"25.1.6.\u00a0The Autovacuum Daemon\">Section\u00a025.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 9.2 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <code class=\"literal\">two_phase = false</code>. After the initial sync, the <code class=\"literal\">two_phase</code> option will be automatically enabled by the subscriber if the subscription had been originally created with <code class=\"literal\">two_phase = true</code> option.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/15/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> below). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.13.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/15/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/15/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/15/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--blobs"], "signature": "-b --blobs", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that blobs are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-blobs"], "signature": "-B --no-blobs", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and blob being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip tool. This format is compressed by default and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as blobs are not dumped when -n is specified. You can add blobs back to the dump with the --blobs switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z 0..9", "--compress= 0..9"], "signature": "-Z 0..9 --compress= 0..9", "description": "Specify the compression level to use. Zero means no compression. For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip ; but the default is not to compress. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns below), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump comments."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "signature": "--no-table-access-method", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.92 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) qualifier match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table qualifiers find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "145309a8b8c908fe8e0b8a82daabf0ff7f2e4fb87ec12c38bf9d24855493d782"}, "16": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "16.15"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "63"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-b --large-objects --blobs (deprecated)"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-B --no-large-objects --no-blobs (deprecated)"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 .", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": {"url": "/docs/16/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--exclude-table-and-children= pattern"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--exclude-table-data-and-children= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump comments.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--no-sync"}}, {"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": {"url": "/docs/16/app-pgdump.html", "text": "--no-table-access-method"}}, {"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": {"url": "/docs/16/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.94 for more details).", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--strict-names"}}, {"summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--table-and-children= pattern"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/16/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/16/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/16/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/16/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/16/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --large-objects --blobs (deprecated)", "source_url": "/docs/16/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-large-objects --no-blobs (deprecated)", "source_url": "/docs/16/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/16/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/16/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/16/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/16/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/16/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/16/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/16/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/16/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/16/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/16/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/16/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/16/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/16/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "source_url": "/docs/16/app-pgdump.html", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/16/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/16/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/16/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/16/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/16/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-and-children= pattern"], "summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-and-children= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-data-and-children= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/16/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/16/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/16/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/16/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/16/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/16/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump comments.", "signature": "--no-comments", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump comments."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/16/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "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": "--no-table-access-method", "source_url": "/docs/16/app-pgdump.html", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/16/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/16/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/16/app-pgdump.html", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/16/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/16/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/16/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/16/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/16/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/16/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.94 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/16/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.94 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/16/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--table-and-children= pattern"], "summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--table-and-children= pattern", "source_url": "/docs/16/app-pgdump.html", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/16/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/16/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/16/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/16/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/16/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/16/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/16/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/16/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/16/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=16", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "label": "16.15", "major": "16", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/16/postgresql-16-A4.pdf", "bytes": 15282337, "pages": 3055, "sha256": "4bb6c1f63deedac98736d8c4c7bc0fad0ac24e85b07e21ee10411872f06afd06", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/16/postgresql-16-US.pdf", "bytes": 15164148, "pages": 3220, "sha256": "5b6b6166c89991199e144bb0ae34c17a5f29826251dbf19db1abc0df3a3e771b", "built_at": "2026-09-26"}}, "tree": "16", "index": "index.html", "major": "16", "pages": 1169, "release": "16.15", "source_url": "https://ftp.postgresql.org/pub/source/v16.15/postgresql-16.15.tar.bz2", "svg_assets": 3, "source_mode": "en HTML verified against the pinned official archive", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "revision": "3c21e58b35318021716440e67bb8bafd392b6a2b965a244d90e9e33c99e0bdef", "evidence_kind": "English manual and source declarations", "source_sha256": "c1575341fa7bd40f5274ea465b34390f4dc64cdd0770af327005caaeb9f6b7ed"}, "sources": [{"url": "/docs/16/app-pgdump.html", "file": "app-pgdump.html", "label": "16.15 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "2a071adab15b4a16ee7707c6f1f321b22d5103535532b4c08fa0eb276af65f55"}, {"url": "/docs/16/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "a28c30c3c0f8783e16d56413a0b6fd39487e336da1683b29b60abf1c229cef26"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.13.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/16/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/16/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/16/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--large-objects</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-large-objects</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/16/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-e</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/16/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"24.3.1.\u00a0Supported Character Sets\">Section\u00a024.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span> tools. This format is compressed by default using <code class=\"literal\">gzip</code> and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/16/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/16/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/16/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as large objects are not dumped when <code class=\"option\">-n</code> is specified. You can add large objects back to the dump with the <code class=\"option\">--large-objects</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/16/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/16/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]<br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]</span></dt>\n<dd>\n<p>Specify the compression method and/or the compression level to use. The compression method can be set to <code class=\"literal\">gzip</code>, <code class=\"literal\">lz4</code>, <code class=\"literal\">zstd</code>, or <code class=\"literal\">none</code> for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form <code class=\"literal\">keyword</code> or <code class=\"literal\">keyword=value</code>. Currently, the supported keywords are <code class=\"literal\">level</code> and <code class=\"literal\">long</code>.</p>\n<p>If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, <code class=\"literal\">gzip</code> compression will be used if the level is greater than <code class=\"literal\">0</code>, and no compression will be used if the level is <code class=\"literal\">0</code>.</p>\n<p>For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using <code class=\"literal\">gzip</code> at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span>; but the default is not to compress. With zstd compression, <code class=\"literal\">long</code> mode may improve the compression ratio, at the cost of increased memory use.</p>\n<p>The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/16/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/16/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">--exclude-table-data</code> option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/16/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/16/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump comments.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-table-access-method</code></span></dt>\n<dd>\n<p>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.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/16/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/16/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.94.\u00a0Snapshot Synchronization Functions\">Table\u00a09.94</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/16/logicaldecoding.html\" title=\"Chapter\u00a049.\u00a0Logical Decoding\">Chapter\u00a049</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) pattern match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table patterns find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> option, except that it also includes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/16/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"34.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.13.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/16/libpq-envars.html\" title=\"34.15.\u00a0Environment Variables\">Section\u00a034.15</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/16/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the cumulative statistics system. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/16/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"25.1.3.\u00a0Updating Planner Statistics\">Section\u00a025.1.3</a> and <a class=\"xref\" href=\"/docs/16/routine-vacuuming.html#AUTOVACUUM\" title=\"25.1.6.\u00a0The Autovacuum Daemon\">Section\u00a025.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 9.2 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <code class=\"literal\">two_phase = false</code>. After the initial sync, the <a class=\"link\" href=\"/docs/16/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-WITH-TWO-PHASE\"><code class=\"literal\">two_phase</code></a> option will be automatically enabled by the subscriber if the subscription had been originally created with <code class=\"literal\">two_phase = true</code> option.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/16/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.13.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/16/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/16/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/16/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "signature": "-b --large-objects --blobs (deprecated)", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "signature": "-B --no-large-objects --no-blobs (deprecated)", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 24.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-table-and-children= pattern"], "signature": "--exclude-table-and-children= pattern", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "signature": "--exclude-table-data-and-children= pattern", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump comments."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "signature": "--no-table-access-method", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.94 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 49 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--table-and-children= pattern"], "signature": "--table-and-children= pattern", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "e6d445c9cc454fe6ecfd7df0014a282e43ce0195b43747c1faf46476099d9b0a"}, "17": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "17.11"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "66"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-b --large-objects --blobs (deprecated)"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-B --no-large-objects --no-blobs (deprecated)"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": {"url": "/docs/17/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--exclude-extension= pattern"}}, {"summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--exclude-table-and-children= pattern"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--exclude-table-data-and-children= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": {"url": "/docs/17/app-pgdump.html", "text": "--filter= filename"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump comments.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--no-sync"}}, {"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": {"url": "/docs/17/app-pgdump.html", "text": "--no-table-access-method"}}, {"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": {"url": "/docs/17/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.98 for more details).", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--strict-names"}}, {"summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--sync-method= method"}}, {"summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--table-and-children= pattern"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/17/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/17/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/17/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/17/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/17/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is.", "signature": "-b --large-objects --blobs (deprecated)", "source_url": "/docs/17/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-large-objects --no-blobs (deprecated)", "source_url": "/docs/17/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/17/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/17/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/17/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/17/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/17/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/17/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/17/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/17/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data.", "signature": "-s --schema-only", "source_url": "/docs/17/app-pgdump.html", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/17/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/17/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/17/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/17/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "source_url": "/docs/17/app-pgdump.html", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/17/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/17/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/17/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/17/app-pgdump.html", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/17/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": "--exclude-extension= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-and-children= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-data-and-children= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/17/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": "--filter= filename", "source_url": "/docs/17/app-pgdump.html", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/17/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/17/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/17/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/17/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/17/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump comments.", "signature": "--no-comments", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump comments."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/17/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "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": "--no-table-access-method", "source_url": "/docs/17/app-pgdump.html", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/17/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/17/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/17/app-pgdump.html", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/17/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/17/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/17/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/17/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/17/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/17/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.98 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/17/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.98 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/17/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": "--sync-method= method", "source_url": "/docs/17/app-pgdump.html", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--table-and-children= pattern", "source_url": "/docs/17/app-pgdump.html", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/17/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/17/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/17/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/17/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/17/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/17/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/17/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/17/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/17/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=17", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "label": "17.11", "major": "17", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/17/postgresql-17-A4.pdf", "bytes": 15521293, "pages": 3099, "sha256": "1991354df0dc89e70ec39328c28988ef8b19c6a93671dab3893650b63e9f4e36", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/17/postgresql-17-US.pdf", "bytes": 15398150, "pages": 3270, "sha256": "07696c8f38abf31babf22d2db337093936e7c472d2af36d050b000c49bbcf52c", "built_at": "2026-09-26"}}, "tree": "17", "index": "index.html", "major": "17", "pages": 1143, "release": "17.11", "source_url": "https://ftp.postgresql.org/pub/source/v17.11/postgresql-17.11.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "revision": "58419c9b0dd42cb34c8d53695bb025a7e582edf55ccd4c5bcb1c2c7c71a37487", "evidence_kind": "English manual and source declarations", "source_sha256": "dd27f2b3c59e73ed14aa3324901242bf69a032a6347805f274e6260322d42979"}, "sources": [{"url": "/docs/17/app-pgdump.html", "file": "app-pgdump.html", "label": "17.11 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "20101bf76517a8d9cc585fae2cd3d1d77e8e332aa5d1a1c60e0f8203d41565a4"}, {"url": "/docs/17/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "3194fc72ddad8e2fcba55f8e007f83413cb352146cb65aaa9457a18d0314ee1b"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 extract a PostgreSQL database into a script file or other archive file"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 extract a <span class=\"productname\">PostgreSQL</span> database into a script file or other archive file</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.14.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for backing up a <span class=\"productname\">PostgreSQL</span> database. It makes consistent backups even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers).</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/17/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/17/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/17/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to backup an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--large-objects</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, or <code class=\"option\">--schema-only</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-large-objects</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/17/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-e</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/17/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"23.3.1.\u00a0Supported Character Sets\">Section\u00a023.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span> tools. This format is compressed by default using <code class=\"literal\">gzip</code> and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/17/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/17/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/17/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/17/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as large objects are not dumped when <code class=\"option\">-n</code> is specified. You can add large objects back to the dump with the <code class=\"option\">--large-objects</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data.</p>\n<p>This option is the inverse of <code class=\"option\">--data-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/17/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/17/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]<br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]</span></dt>\n<dd>\n<p>Specify the compression method and/or the compression level to use. The compression method can be set to <code class=\"literal\">gzip</code>, <code class=\"literal\">lz4</code>, <code class=\"literal\">zstd</code>, or <code class=\"literal\">none</code> for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form <code class=\"literal\">keyword</code> or <code class=\"literal\">keyword=value</code>. Currently, the supported keywords are <code class=\"literal\">level</code> and <code class=\"literal\">long</code>.</p>\n<p>If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, <code class=\"literal\">gzip</code> compression will be used if the level is greater than <code class=\"literal\">0</code>, and no compression will be used if the level is <code class=\"literal\">0</code>.</p>\n<p>For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using <code class=\"literal\">gzip</code> at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span>; but the default is not to compress. With zstd compression, <code class=\"literal\">long</code> mode may improve the compression ratio, at the cost of increased memory use.</p>\n<p>The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a data-only dump. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/17/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/17/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any extensions matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-e</code>. <code class=\"option\">--exclude-extension</code> can be given more than once to exclude extensions matching any of several patterns.</p>\n<p>When both <code class=\"option\">-e</code> and <code class=\"option\">--exclude-extension</code> are given, the behavior is to dump just the extensions that match at least one <code class=\"option\">-e</code> switch but no <code class=\"option\">--exclude-extension</code> switches. If <code class=\"option\">--exclude-extension</code> appears without <code class=\"option\">-e</code>, then extensions matching <code class=\"option\">--exclude-extension</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">--exclude-table-data</code> option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--filter=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: <code class=\"option\">-t</code>/<code class=\"option\">--table</code>, <code class=\"option\">--table-and-children</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, and <code class=\"option\">--exclude-table-and-children</code> for tables, <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> and <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> for schemas, <code class=\"option\">--include-foreign-data</code> for data on foreign servers, <code class=\"option\">--exclude-table-data</code> and <code class=\"option\">--exclude-table-data-and-children</code> for table data, and <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> and <code class=\"option\">--exclude-extension</code> for extensions. To read from <code class=\"literal\">STDIN</code>, use <code class=\"filename\">-</code> as the filename. The <code class=\"option\">--filter</code> 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.</p>\n<p>The file lists one object pattern per row, with the following format:</p>\n<pre class=\"synopsis\">{ include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } <em class=\"replaceable\"><code>PATTERN</code></em>\n</pre>\n<p>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:</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\">\n<p><code class=\"literal\">extension</code>: extensions. This works like the <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> or <code class=\"option\">--exclude-extension</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">foreign_data</code>: data on foreign servers. This works like the <code class=\"option\">--include-foreign-data</code> option. This keyword can only be used with the <code class=\"literal\">include</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table</code>: tables. This works like the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> or <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_and_children</code>: tables including any partitions or inheritance child tables. This works like the <code class=\"option\">--table-and-children</code> or <code class=\"option\">--exclude-table-and-children</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em>. This works like the <code class=\"option\">--exclude-table-data</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data_and_children</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em> as well as any partitions or inheritance children of the table(s). This works like the <code class=\"option\">--exclude-table-data-and-children</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">schema</code>: schemas. This works like the <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> or <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> option.</p>\n</li>\n</ul>\n</div>\n<p>Lines starting with <code class=\"literal\">#</code> are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See <a class=\"xref\" href=\"/docs/17/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> for how to perform quoting in patterns.</p>\n<p>Example files are listed below in the <a class=\"xref\" href=\"/docs/17/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> section.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/17/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/17/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump comments.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-table-access-method</code></span></dt>\n<dd>\n<p>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.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/17/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/17/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.98.\u00a0Snapshot Synchronization Functions\">Table\u00a09.98</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/17/logicaldecoding.html\" title=\"Chapter\u00a047.\u00a0Logical Decoding\">Chapter\u00a047</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with <code class=\"option\">--filter</code>. Note that if none of the extension/schema/table patterns find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">--exclude-extension</code>, <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p>When set to <code class=\"literal\">fsync</code>, which is the default, <code class=\"command\">pg_dump --format=directory</code> will recursively open and synchronize all files in the archive directory.</p>\n<p>On Linux, <code class=\"literal\">syncfs</code> may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See <a class=\"xref\" href=\"/docs/17/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a> for information about the caveats to be aware of when using <code class=\"literal\">syncfs</code>.</p>\n<p>This option has no effect when <code class=\"option\">--no-sync</code> is used or <code class=\"option\">--format</code> is not set to <code class=\"literal\">directory</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> option, except that it also includes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/17/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/17/libpq-envars.html\" title=\"32.15.\u00a0Environment Variables\">Section\u00a032.15</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/17/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the cumulative statistics system. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a data-only dump is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>The dump file produced by <span class=\"application\">pg_dump</span> does not contain the statistics used by the optimizer to make query planning decisions. Therefore, it is wise to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/17/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/17/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 9.2 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <code class=\"literal\">two_phase = false</code>. After the initial sync, the <a class=\"link\" href=\"/docs/17/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-TWO-PHASE\"><code class=\"literal\">two_phase</code></a> option will be automatically enabled by the subscriber if the subscription had been originally created with <code class=\"literal\">two_phase = true</code> option.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/17/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">mytable</code>, except for table <code class=\"literal\">mytable2</code>, specify a filter file <code class=\"filename\">filter.txt</code> like:</p>\n<pre class=\"programlisting\">include table mytable*\nexclude table mytable2\n</pre>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump --filter=filter.txt mydb &gt; db.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/17/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/17/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/17/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions). Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "signature": "-b --large-objects --blobs (deprecated)", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , or --schema-only is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "signature": "-B --no-large-objects --no-blobs (deprecated)", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data. This option is the inverse of --data-only . It is similar to, but for historical reasons not identical to, specifying --section=pre-data --section=post-data . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a data-only dump. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "signature": "--exclude-extension= pattern", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "signature": "--exclude-table-and-children= pattern", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "signature": "--exclude-table-data-and-children= pattern", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "signature": "--filter= filename", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump comments."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "signature": "--no-table-access-method", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, and sequence values. Post-data items include definitions of indexes, triggers, rules, and constraints other than validated check constraints. Pre-data items include all other data definition items."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.98 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "signature": "--table-and-children= pattern", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "fa45a8fa5d81d236bed47009c044efc2d9a63d1a7a2dfcc568a8472547a05fff"}, "18": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "18.6"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "73"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-b --large-objects --blobs (deprecated)"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-B --no-large-objects --no-blobs (deprecated)"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data or statistics.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": {"url": "/docs/18/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-extension= pattern"}}, {"summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-table-and-children= pattern"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-table-data-and-children= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": {"url": "/docs/18/app-pgdump.html", "text": "--filter= filename"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump COMMENT commands.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump data.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-data"}}, {"summary": "Do not dump row security policies.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-policies"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump schema (data definitions).", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-schema"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump statistics. This is the default.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-statistics"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-sync"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "--no-table-access-method"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--sequence-data"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details).", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Dump optimizer statistics.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--statistics"}}, {"summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--statistics-only"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--strict-names"}}, {"summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--sync-method= method"}}, {"summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--table-and-children= pattern"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": "-b --large-objects --blobs (deprecated)", "source_url": "/docs/18/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-large-objects --no-blobs (deprecated)", "source_url": "/docs/18/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/18/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/18/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/18/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/18/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/18/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/18/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/18/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/18/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data or statistics.", "signature": "-s --schema-only", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/18/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/18/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/18/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/18/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "source_url": "/docs/18/app-pgdump.html", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/18/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/18/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/18/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/18/app-pgdump.html", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/18/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": "--exclude-extension= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-and-children= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-data-and-children= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/18/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": "--filter= filename", "source_url": "/docs/18/app-pgdump.html", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/18/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/18/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/18/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/18/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/18/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump COMMENT commands.", "signature": "--no-comments", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "summary": "Do not dump data.", "signature": "--no-data", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump data."}, {"names": ["--no-policies"], "summary": "Do not dump row security policies.", "signature": "--no-policies", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-schema"], "summary": "Do not dump schema (data definitions).", "signature": "--no-schema", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "summary": "Do not dump statistics. This is the default.", "signature": "--no-statistics", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/18/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "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": "--no-table-access-method", "source_url": "/docs/18/app-pgdump.html", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/18/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/18/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/18/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/18/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/18/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/18/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/18/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": "--sequence-data", "source_url": "/docs/18/app-pgdump.html", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/18/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/18/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "summary": "Dump optimizer statistics.", "signature": "--statistics", "source_url": "/docs/18/app-pgdump.html", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": "--statistics-only", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/18/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": "--sync-method= method", "source_url": "/docs/18/app-pgdump.html", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--table-and-children= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/18/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/18/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/18/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/18/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/18/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/18/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/18/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/18/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/18/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=18", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "/docs/18/app-pgdump.html", "file": "app-pgdump.html", "label": "18.6 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "758860baaa3462061cc6343b8d04559ec3fbc9e77c00e426f5eb8b32c863509e"}, {"url": "/docs/18/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 export a PostgreSQL database as an SQL script or to other formats"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 export a <span class=\"productname\">PostgreSQL</span> database as an SQL script or to other formats</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.14.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for exporting a <span class=\"productname\">PostgreSQL</span> database. It makes consistent exports even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers). Note, however, that except in simple cases, <span class=\"application\">pg_dump</span> is generally not the right choice for taking regular backups of production databases. See <a class=\"xref\" href=\"/docs/18/backup.html\" title=\"Chapter\u00a025.\u00a0Backup and Restore\">Chapter\u00a025</a> for further discussion.</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To export an entire cluster, or to export global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/18/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to export an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--large-objects</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, <code class=\"option\">--schema-only</code>, <code class=\"option\">--statistics-only</code>, or <code class=\"option\">--no-data</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-large-objects</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-e</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/18/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"23.3.1.\u00a0Supported Character Sets\">Section\u00a023.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span> tools. This format is compressed by default using <code class=\"literal\">gzip</code> and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/18/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as large objects are not dumped when <code class=\"option\">-n</code> is specified. You can add large objects back to the dump with the <code class=\"option\">--large-objects</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data or statistics.</p>\n<p>This option cannot be used with <code class=\"option\">--data-only</code> or <code class=\"option\">--statistics-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]<br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]</span></dt>\n<dd>\n<p>Specify the compression method and/or the compression level to use. The compression method can be set to <code class=\"literal\">gzip</code>, <code class=\"literal\">lz4</code>, <code class=\"literal\">zstd</code>, or <code class=\"literal\">none</code> for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form <code class=\"literal\">keyword</code> or <code class=\"literal\">keyword=value</code>. Currently, the supported keywords are <code class=\"literal\">level</code> and <code class=\"literal\">long</code>.</p>\n<p>If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, <code class=\"literal\">gzip</code> compression will be used if the level is greater than <code class=\"literal\">0</code>, and no compression will be used if the level is <code class=\"literal\">0</code>.</p>\n<p>For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using <code class=\"literal\">gzip</code> at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span>; but the default is not to compress. With zstd compression, <code class=\"literal\">long</code> mode may improve the compression ratio, at the cost of increased memory use.</p>\n<p>The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a dump that includes data but does not include schema. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any extensions matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-e</code>. <code class=\"option\">--exclude-extension</code> can be given more than once to exclude extensions matching any of several patterns.</p>\n<p>When both <code class=\"option\">-e</code> and <code class=\"option\">--exclude-extension</code> are given, the behavior is to dump just the extensions that match at least one <code class=\"option\">-e</code> switch but no <code class=\"option\">--exclude-extension</code> switches. If <code class=\"option\">--exclude-extension</code> appears without <code class=\"option\">-e</code>, then extensions matching <code class=\"option\">--exclude-extension</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">--exclude-table-data</code> option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--filter=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: <code class=\"option\">-t</code>/<code class=\"option\">--table</code>, <code class=\"option\">--table-and-children</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, and <code class=\"option\">--exclude-table-and-children</code> for tables, <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> and <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> for schemas, <code class=\"option\">--include-foreign-data</code> for data on foreign servers, <code class=\"option\">--exclude-table-data</code> and <code class=\"option\">--exclude-table-data-and-children</code> for table data, and <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> and <code class=\"option\">--exclude-extension</code> for extensions. To read from <code class=\"literal\">STDIN</code>, use <code class=\"filename\">-</code> as the filename. The <code class=\"option\">--filter</code> 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.</p>\n<p>The file lists one object pattern per row, with the following format:</p>\n<pre class=\"synopsis\">{ include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } <em class=\"replaceable\"><code>PATTERN</code></em>\n</pre>\n<p>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:</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\">\n<p><code class=\"literal\">extension</code>: extensions. This works like the <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> or <code class=\"option\">--exclude-extension</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">foreign_data</code>: data on foreign servers. This works like the <code class=\"option\">--include-foreign-data</code> option. This keyword can only be used with the <code class=\"literal\">include</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table</code>: tables. This works like the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> or <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_and_children</code>: tables including any partitions or inheritance child tables. This works like the <code class=\"option\">--table-and-children</code> or <code class=\"option\">--exclude-table-and-children</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em>. This works like the <code class=\"option\">--exclude-table-data</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data_and_children</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em> as well as any partitions or inheritance children of the table(s). This works like the <code class=\"option\">--exclude-table-data-and-children</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">schema</code>: schemas. This works like the <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> or <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> option.</p>\n</li>\n</ul>\n</div>\n<p>Lines starting with <code class=\"literal\">#</code> are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> for how to perform quoting in patterns.</p>\n<p>Example files are listed below in the <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> section.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump <code class=\"command\">COMMENT</code> commands.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-data</code></span></dt>\n<dd>\n<p>Do not dump data.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-policies</code></span></dt>\n<dd>\n<p>Do not dump row security policies.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-schema</code></span></dt>\n<dd>\n<p>Do not dump schema (data definitions).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p>Do not dump statistics. This is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-table-access-method</code></span></dt>\n<dd>\n<p>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.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sequence-data</code></span></dt>\n<dd>\n<p>Include sequence data in the dump. This is the default behavior except when <code class=\"option\">--no-data</code>, <code class=\"option\">--schema-only</code>, or <code class=\"option\">--statistics-only</code> is specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/18/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/18/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.100.\u00a0Snapshot Synchronization Functions\">Table\u00a09.100</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/18/logicaldecoding.html\" title=\"Chapter\u00a047.\u00a0Logical Decoding\">Chapter\u00a047</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics</code></span></dt>\n<dd>\n<p>Dump optimizer statistics.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics-only</code></span></dt>\n<dd>\n<p>Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with <code class=\"option\">--filter</code>. Note that if none of the extension/schema/table patterns find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">--exclude-extension</code>, <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p>When set to <code class=\"literal\">fsync</code>, which is the default, <code class=\"command\">pg_dump --format=directory</code> will recursively open and synchronize all files in the archive directory.</p>\n<p>On Linux, <code class=\"literal\">syncfs</code> may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See <a class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a> for information about the caveats to be aware of when using <code class=\"literal\">syncfs</code>.</p>\n<p>This option has no effect when <code class=\"option\">--no-sync</code> is used or <code class=\"option\">--format</code> is not set to <code class=\"literal\">directory</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> option, except that it also includes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15.\u00a0Environment Variables\">Section\u00a032.15</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the cumulative statistics system. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a dump without schema is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>When <code class=\"option\">--statistics</code> is specified, <code class=\"command\">pg_dump</code> will include most optimizer statistics in the resulting dump file. This does not include all statistics, such as those created explicitly with <a class=\"xref\" href=\"/docs/18/sql-createstatistics.html\" title=\"CREATE STATISTICS\"><span class=\"refentrytitle\">CREATE STATISTICS</span></a>, custom statistics added by an extension, or statistics collected by the cumulative statistics system. Therefore, it may still be useful to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/18/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/18/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 9.2 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <code class=\"literal\">two_phase = false</code>. After the initial sync, the <a class=\"link\" href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-TWO-PHASE\"><code class=\"literal\">two_phase</code></a> option will be automatically enabled by the subscriber if the subscription had been originally created with <code class=\"literal\">two_phase = true</code> option.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">mytable</code>, except for table <code class=\"literal\">mytable2</code>, specify a filter file <code class=\"filename\">filter.txt</code> like:</p>\n<pre class=\"programlisting\">include table mytable*\nexclude table mytable2\n</pre>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump --filter=filter.txt mydb &gt; db.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/18/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "signature": "-b --large-objects --blobs (deprecated)", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "signature": "-B --no-large-objects --no-blobs (deprecated)", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "signature": "--exclude-extension= pattern", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "signature": "--exclude-table-and-children= pattern", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "signature": "--exclude-table-data-and-children= pattern", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "signature": "--filter= filename", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "signature": "--no-data", "description": "Do not dump data."}, {"names": ["--no-policies"], "signature": "--no-policies", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-schema"], "signature": "--no-schema", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "signature": "--no-table-access-method", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "signature": "--sequence-data", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "signature": "--statistics", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "signature": "--statistics-only", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "signature": "--table-and-children= pattern", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "e4fc1961ca5ae638ffddf6b82d9336086bc97a70b652b15a5b41f476128da561"}, "19": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "19beta4"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "73"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-b --large-objects --blobs (deprecated)"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-B --no-large-objects --no-blobs (deprecated)"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data or statistics.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": {"url": "/docs/19/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--exclude-extension= pattern"}}, {"summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--exclude-table-and-children= pattern"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--exclude-table-data-and-children= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": {"url": "/docs/19/app-pgdump.html", "text": "--filter= filename"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump COMMENT commands.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump data.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-data"}}, {"summary": "Do not dump row security policies.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-policies"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump schema (data definitions).", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-schema"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump statistics. This is the default.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-statistics"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-sync"}}, {"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": {"url": "/docs/19/app-pgdump.html", "text": "--no-table-access-method"}}, {"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": {"url": "/docs/19/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--sequence-data"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.101 for more details).", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Dump optimizer statistics.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--statistics"}}, {"summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--statistics-only"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--strict-names"}}, {"summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--sync-method= method"}}, {"summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--table-and-children= pattern"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/19/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/19/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/19/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/19/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/19/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": "-b --large-objects --blobs (deprecated)", "source_url": "/docs/19/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-large-objects --no-blobs (deprecated)", "source_url": "/docs/19/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/19/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/19/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note pg_dump does not dump the extension's underlying installation files (such as shared libraries or control files). These must be available on the destination system for the restore to succeed."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/19/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty.", "signature": "-f file --file= file", "source_url": "/docs/19/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/19/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/19/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/19/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/19/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data or statistics.", "signature": "-s --schema-only", "source_url": "/docs/19/app-pgdump.html", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/19/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/19/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/19/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/19/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "source_url": "/docs/19/app-pgdump.html", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/19/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/19/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/19/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/19/app-pgdump.html", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/19/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": "--exclude-extension= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-and-children= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-data-and-children= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/19/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": "--filter= filename", "source_url": "/docs/19/app-pgdump.html", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/19/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/19/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/19/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/19/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/19/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump COMMENT commands.", "signature": "--no-comments", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "summary": "Do not dump data.", "signature": "--no-data", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump data."}, {"names": ["--no-policies"], "summary": "Do not dump row security policies.", "signature": "--no-policies", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-schema"], "summary": "Do not dump schema (data definitions).", "signature": "--no-schema", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "summary": "Do not dump statistics. This is the default.", "signature": "--no-statistics", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/19/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "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": "--no-table-access-method", "source_url": "/docs/19/app-pgdump.html", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/19/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/19/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/19/app-pgdump.html", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/19/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/19/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/19/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/19/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/19/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": "--sequence-data", "source_url": "/docs/19/app-pgdump.html", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/19/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.101 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/19/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.101 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "summary": "Dump optimizer statistics.", "signature": "--statistics", "source_url": "/docs/19/app-pgdump.html", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": "--statistics-only", "source_url": "/docs/19/app-pgdump.html", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/19/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": "--sync-method= method", "source_url": "/docs/19/app-pgdump.html", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--table-and-children= pattern", "source_url": "/docs/19/app-pgdump.html", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/19/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/19/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/19/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/19/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/19/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/19/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/19/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/19/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/19/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=19", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "label": "19beta4", "major": "19", "channel": "preview", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/19/postgresql-19-A4.pdf", "bytes": 16064841, "pages": 3052, "sha256": "4dd099e4125c591128fc5f3ebd02178dc24781f9e5ae629f96d67c4c8547427b", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/19/postgresql-19-US.pdf", "bytes": 15974616, "pages": 3225, "sha256": "61971fa857f0956d47341a0388fa6af9ae10acf691d4b2fc009007d384b0342b", "built_at": "2026-09-26"}}, "tree": "19", "index": "index.html", "major": "19", "pages": 1155, "release": "19beta4", "source_url": "https://ftp.postgresql.org/pub/source/v19beta4/postgresql-19beta4.tar.bz2", "svg_assets": 5, "source_mode": "en SGML built with pinned official archive", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "revision": "1bbbbf4133d426f0e4304010688d2984c30fb67df0cc3a61b3e37eb3f6f37833", "evidence_kind": "English manual and source declarations", "source_sha256": "83157ee9c599d03b2f7a3d73ef3a56ec24e0e79cc2b3501a64d1364f56398c86"}, "sources": [{"url": "/docs/19/app-pgdump.html", "file": "app-pgdump.html", "label": "19beta4 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "f89df9101a17f8b5d42f73eccd5660ed1d2bce4df2001ae45fdbd75e9caa7e5d"}, {"url": "/docs/19/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "c827f460db781b39da305303c88e73729a419cd2b2b9dedb126d8ad5cbf02c95"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 export a PostgreSQL database as an SQL script or to other formats"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 export a <span class=\"productname\">PostgreSQL</span> database as an SQL script or to other formats</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.14.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for exporting a <span class=\"productname\">PostgreSQL</span> database. It makes consistent exports even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers). Note, however, that except in simple cases, <span class=\"application\">pg_dump</span> is generally not the right choice for taking regular backups of production databases. See <a class=\"xref\" href=\"/docs/19/backup.html\" title=\"Chapter\u00a025.\u00a0Backup and Restore\">Chapter\u00a025</a> for further discussion.</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To export an entire cluster, or to export global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/19/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/19/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/19/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to export an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--large-objects</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, <code class=\"option\">--schema-only</code>, <code class=\"option\">--statistics-only</code>, or <code class=\"option\">--no-data</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-large-objects</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/19/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><span class=\"application\">pg_dump</span> does not dump the extension's underlying installation files (such as shared libraries or control files). These must be available on the destination system for the restore to succeed.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/19/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"23.3.1.\u00a0Supported Character Sets\">Section\u00a023.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> unless the directory exists and is empty.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span> tools. This format is compressed by default using <code class=\"literal\">gzip</code> and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/19/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/19/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/19/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/19/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as large objects are not dumped when <code class=\"option\">-n</code> is specified. You can add large objects back to the dump with the <code class=\"option\">--large-objects</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data or statistics.</p>\n<p>This option cannot be used with <code class=\"option\">--data-only</code> or <code class=\"option\">--statistics-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/19/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/19/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]<br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]</span></dt>\n<dd>\n<p>Specify the compression method and/or the compression level to use. The compression method can be set to <code class=\"literal\">gzip</code>, <code class=\"literal\">lz4</code>, <code class=\"literal\">zstd</code>, or <code class=\"literal\">none</code> for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form <code class=\"literal\">keyword</code> or <code class=\"literal\">keyword=value</code>. Currently, the supported keywords are <code class=\"literal\">level</code> and <code class=\"literal\">long</code>.</p>\n<p>If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, <code class=\"literal\">gzip</code> compression will be used if the level is greater than <code class=\"literal\">0</code>, and no compression will be used if the level is <code class=\"literal\">0</code>.</p>\n<p>For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using <code class=\"literal\">gzip</code> at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span>; but the default is not to compress. With zstd compression, <code class=\"literal\">long</code> mode may improve the compression ratio, at the cost of increased memory use.</p>\n<p>The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a dump that includes data but does not include schema. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/19/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/19/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any extensions matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-e</code>. <code class=\"option\">--exclude-extension</code> can be given more than once to exclude extensions matching any of several patterns.</p>\n<p>When both <code class=\"option\">-e</code> and <code class=\"option\">--exclude-extension</code> are given, the behavior is to dump just the extensions that match at least one <code class=\"option\">-e</code> switch but no <code class=\"option\">--exclude-extension</code> switches. If <code class=\"option\">--exclude-extension</code> appears without <code class=\"option\">-e</code>, then extensions matching <code class=\"option\">--exclude-extension</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">--exclude-table-data</code> option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--filter=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: <code class=\"option\">-t</code>/<code class=\"option\">--table</code>, <code class=\"option\">--table-and-children</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, and <code class=\"option\">--exclude-table-and-children</code> for tables, <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> and <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> for schemas, <code class=\"option\">--include-foreign-data</code> for data on foreign servers, <code class=\"option\">--exclude-table-data</code> and <code class=\"option\">--exclude-table-data-and-children</code> for table data, and <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> and <code class=\"option\">--exclude-extension</code> for extensions. To read from <code class=\"literal\">STDIN</code>, use <code class=\"filename\">-</code> as the filename. The <code class=\"option\">--filter</code> 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.</p>\n<p>The file lists one object pattern per row, with the following format:</p>\n<pre class=\"synopsis\">{ include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } <em class=\"replaceable\"><code>PATTERN</code></em>\n</pre>\n<p>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:</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\">\n<p><code class=\"literal\">extension</code>: extensions. This works like the <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> or <code class=\"option\">--exclude-extension</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">foreign_data</code>: data on foreign servers. This works like the <code class=\"option\">--include-foreign-data</code> option. This keyword can only be used with the <code class=\"literal\">include</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table</code>: tables. This works like the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> or <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_and_children</code>: tables including any partitions or inheritance child tables. This works like the <code class=\"option\">--table-and-children</code> or <code class=\"option\">--exclude-table-and-children</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em>. This works like the <code class=\"option\">--exclude-table-data</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data_and_children</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em> as well as any partitions or inheritance children of the table(s). This works like the <code class=\"option\">--exclude-table-data-and-children</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">schema</code>: schemas. This works like the <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> or <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> option.</p>\n</li>\n</ul>\n</div>\n<p>Lines starting with <code class=\"literal\">#</code> are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See <a class=\"xref\" href=\"/docs/19/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> for how to perform quoting in patterns.</p>\n<p>Example files are listed below in the <a class=\"xref\" href=\"/docs/19/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> section.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/19/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/19/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump <code class=\"command\">COMMENT</code> commands.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-data</code></span></dt>\n<dd>\n<p>Do not dump data.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-policies</code></span></dt>\n<dd>\n<p>Do not dump row security policies.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-schema</code></span></dt>\n<dd>\n<p>Do not dump schema (data definitions).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p>Do not dump statistics. This is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-table-access-method</code></span></dt>\n<dd>\n<p>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.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sequence-data</code></span></dt>\n<dd>\n<p>Include sequence data in the dump. This is the default behavior except when <code class=\"option\">--no-data</code>, <code class=\"option\">--schema-only</code>, or <code class=\"option\">--statistics-only</code> is specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/19/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/19/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.101.\u00a0Snapshot Synchronization Functions\">Table\u00a09.101</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/19/logicaldecoding.html\" title=\"Chapter\u00a047.\u00a0Logical Decoding\">Chapter\u00a047</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics</code></span></dt>\n<dd>\n<p>Dump optimizer statistics.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics-only</code></span></dt>\n<dd>\n<p>Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with <code class=\"option\">--filter</code>. Note that if none of the extension/schema/table patterns find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">--exclude-extension</code>, <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p>When set to <code class=\"literal\">fsync</code>, which is the default, <code class=\"command\">pg_dump --format=directory</code> will recursively open and synchronize all files in the archive directory.</p>\n<p>On Linux, <code class=\"literal\">syncfs</code> may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See <a class=\"xref\" href=\"/docs/19/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a> for information about the caveats to be aware of when using <code class=\"literal\">syncfs</code>.</p>\n<p>This option has no effect when <code class=\"option\">--no-sync</code> is used or <code class=\"option\">--format</code> is not set to <code class=\"literal\">directory</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> option, except that it also includes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/19/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/19/libpq-envars.html\" title=\"32.15.\u00a0Environment Variables\">Section\u00a032.15</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/19/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the cumulative statistics system. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When options <code class=\"option\">-e</code>, <code class=\"option\">-n</code> or <code class=\"option\">-t</code> are specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected object(s) might depend upon. Therefore, there is no guarantee that the results of a dump so generated can be successfully restored by themselves into a clean database. For example, if a table whose definition includes a foreign key is specified to be restored, the table referenced by the foreign key is not automatically restored.</p>\n<p>When a dump without schema is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>When creating an archive (non-text) output file, it is advisable not to restrict the set of database objects dumped, but instead plan to apply any desired object filtering when reading the archive with <span class=\"application\">pg_restore</span>. This will preserve flexibility and possibly avoid problems at restore time; for details see the <a class=\"xref\" href=\"/docs/19/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> documentation. In particular, dumping table data without the corresponding table definition (via <code class=\"option\">--no-schema</code> and related options) is not recommended.</p>\n<p>When <code class=\"option\">--statistics</code> is specified, <code class=\"command\">pg_dump</code> will include most optimizer statistics in the resulting dump file. This does not include all statistics, such as custom statistics added by an extension, or statistics collected by the cumulative statistics system. Therefore, it may still be useful to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/19/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/19/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 9.2 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <code class=\"literal\">two_phase = false</code>. After the initial sync, the <a class=\"link\" href=\"/docs/19/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-TWO-PHASE\"><code class=\"literal\">two_phase</code></a> option will be automatically enabled by the subscriber if the subscription had been originally created with <code class=\"literal\">two_phase = true</code> option.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/19/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">mytable</code>, except for table <code class=\"structname\">mytable2</code>, specify a filter file <code class=\"filename\">filter.txt</code> like:</p>\n<pre class=\"programlisting\">include table mytable*\nexclude table mytable2\n</pre>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump --filter=filter.txt mydb &gt; db.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/19/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/19/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/19/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "signature": "-b --large-objects --blobs (deprecated)", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "signature": "-B --no-large-objects --no-blobs (deprecated)", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note pg_dump does not dump the extension's underlying installation files (such as shared libraries or control files). These must be available on the destination system for the restore to succeed."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "signature": "--exclude-extension= pattern", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "signature": "--exclude-table-and-children= pattern", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "signature": "--exclude-table-data-and-children= pattern", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "signature": "--filter= filename", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "signature": "--no-data", "description": "Do not dump data."}, {"names": ["--no-policies"], "signature": "--no-policies", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-schema"], "signature": "--no-schema", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "signature": "--no-table-access-method", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "signature": "--sequence-data", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.101 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "signature": "--statistics", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "signature": "--statistics-only", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "signature": "--table-and-children= pattern", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "49d8bd5ff303805fbeaed2fd55253ee4b480846687aa14e5b3d4b768c6d653c0"}, "20": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "20devel"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "73"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-b --large-objects --blobs (deprecated)"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-B --no-large-objects --no-blobs (deprecated)"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data or statistics.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": {"url": "/docs/devel/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--exclude-extension= pattern"}}, {"summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--exclude-table-and-children= pattern"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--exclude-table-data-and-children= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": {"url": "/docs/devel/app-pgdump.html", "text": "--filter= filename"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump COMMENT commands.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump data.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-data"}}, {"summary": "Do not dump row security policies.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-policies"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump schema (data definitions).", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-schema"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump statistics. This is the default.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-statistics"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-sync"}}, {"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": {"url": "/docs/devel/app-pgdump.html", "text": "--no-table-access-method"}}, {"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": {"url": "/docs/devel/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--sequence-data"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.102 for more details).", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Dump optimizer statistics.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--statistics"}}, {"summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--statistics-only"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--strict-names"}}, {"summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--sync-method= method"}}, {"summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--table-and-children= pattern"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/devel/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/devel/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/devel/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/devel/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": "-b --large-objects --blobs (deprecated)", "source_url": "/docs/devel/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-large-objects --no-blobs (deprecated)", "source_url": "/docs/devel/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/devel/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/devel/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note pg_dump does not dump the extension's underlying installation files (such as shared libraries or control files). These must be available on the destination system for the restore to succeed."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/devel/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty.", "signature": "-f file --file= file", "source_url": "/docs/devel/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/devel/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/devel/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/devel/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data or statistics.", "signature": "-s --schema-only", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/devel/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/devel/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/devel/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/devel/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "source_url": "/docs/devel/app-pgdump.html", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/devel/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/devel/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/devel/app-pgdump.html", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/devel/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": "--exclude-extension= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-and-children= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-data-and-children= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/devel/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": "--filter= filename", "source_url": "/docs/devel/app-pgdump.html", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/devel/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/devel/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump COMMENT commands.", "signature": "--no-comments", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "summary": "Do not dump data.", "signature": "--no-data", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump data."}, {"names": ["--no-policies"], "summary": "Do not dump row security policies.", "signature": "--no-policies", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-schema"], "summary": "Do not dump schema (data definitions).", "signature": "--no-schema", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "summary": "Do not dump statistics. This is the default.", "signature": "--no-statistics", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/devel/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "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": "--no-table-access-method", "source_url": "/docs/devel/app-pgdump.html", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/devel/app-pgdump.html", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/devel/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/devel/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/devel/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/devel/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": "--sequence-data", "source_url": "/docs/devel/app-pgdump.html", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/devel/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.102 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/devel/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.102 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "summary": "Dump optimizer statistics.", "signature": "--statistics", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": "--statistics-only", "source_url": "/docs/devel/app-pgdump.html", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/devel/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": "--sync-method= method", "source_url": "/docs/devel/app-pgdump.html", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--table-and-children= pattern", "source_url": "/docs/devel/app-pgdump.html", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/devel/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/devel/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/devel/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/devel/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/devel/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/devel/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/devel/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/devel/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/devel/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=20", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "label": "20devel", "major": "20", "channel": "devel", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/20/postgresql-20-A4.pdf", "bytes": 16030631, "pages": 3052, "sha256": "bd5d82c0ce38fc18f92a0447818a91a193a261776bca1c37564bf9a683e177d0", "built_at": "2026-09-28"}, "US": {"url": "/files/documentation/pdf/20/postgresql-20-US.pdf", "bytes": 15936613, "pages": 3223, "sha256": "d97d9e0db479a02f4234b175f50fcad70c3661619afc8d6df9b9437882e3c299", "built_at": "2026-09-28"}}, "tree": "0", "index": "index.html", "major": "20", "pages": 1156, "release": "20devel", "source_url": "https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.tar.bz2", "svg_assets": 6, "source_mode": "en SGML built with pinned official archive", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41", "source_snapshot_utc": "26-Sep-2026 20:22"}, "revision": "2eba5e0fd4c3bffb2803247b6cd537878e9d6ee5a6dfbe3c50ece8b421b80918", "evidence_kind": "English manual and source declarations", "source_sha256": "4d3346909b201ac1648232cf290462a7070c119326f56196f1f0253ed80fae41"}, "sources": [{"url": "/docs/devel/app-pgdump.html", "file": "app-pgdump.html", "label": "20devel English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "4e1f336a3eb075e3f20f40e8e31409b35036feeea65b4aa449f53bd194cf20c0"}, {"url": "/docs/devel/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "a6c7ba748fa1d9feac5bb7cde41d1d36a1f4c26d5963e07fb103d02918b2a8ca"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 export a PostgreSQL database as an SQL script or to other formats"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 export a <span class=\"productname\">PostgreSQL</span> database as an SQL script or to other formats</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.14.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for exporting a <span class=\"productname\">PostgreSQL</span> database. It makes consistent exports even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers). Note, however, that except in simple cases, <span class=\"application\">pg_dump</span> is generally not the right choice for taking regular backups of production databases. See <a class=\"xref\" href=\"/docs/devel/backup.html\" title=\"Chapter\u00a025.\u00a0Backup and Restore\">Chapter\u00a025</a> for further discussion.</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To export an entire cluster, or to export global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/devel/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/devel/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/devel/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to export an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--large-objects</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, <code class=\"option\">--schema-only</code>, <code class=\"option\">--statistics-only</code>, or <code class=\"option\">--no-data</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-large-objects</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/devel/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p><span class=\"application\">pg_dump</span> does not dump the extension's underlying installation files (such as shared libraries or control files). These must be available on the destination system for the restore to succeed.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/devel/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"23.3.1.\u00a0Supported Character Sets\">Section\u00a023.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> unless the directory exists and is empty.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span> tools. This format is compressed by default using <code class=\"literal\">gzip</code> and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/devel/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/devel/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/devel/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/devel/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as large objects are not dumped when <code class=\"option\">-n</code> is specified. You can add large objects back to the dump with the <code class=\"option\">--large-objects</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data or statistics.</p>\n<p>This option cannot be used with <code class=\"option\">--data-only</code> or <code class=\"option\">--statistics-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/devel/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/devel/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]<br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]</span></dt>\n<dd>\n<p>Specify the compression method and/or the compression level to use. The compression method can be set to <code class=\"literal\">gzip</code>, <code class=\"literal\">lz4</code>, <code class=\"literal\">zstd</code>, or <code class=\"literal\">none</code> for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form <code class=\"literal\">keyword</code> or <code class=\"literal\">keyword=value</code>. Currently, the supported keywords are <code class=\"literal\">level</code> and <code class=\"literal\">long</code>.</p>\n<p>If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, <code class=\"literal\">gzip</code> compression will be used if the level is greater than <code class=\"literal\">0</code>, and no compression will be used if the level is <code class=\"literal\">0</code>.</p>\n<p>For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using <code class=\"literal\">gzip</code> at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span>; but the default is not to compress. With zstd compression, <code class=\"literal\">long</code> mode may improve the compression ratio, at the cost of increased memory use.</p>\n<p>The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a dump that includes data but does not include schema. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/devel/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/devel/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any extensions matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-e</code>. <code class=\"option\">--exclude-extension</code> can be given more than once to exclude extensions matching any of several patterns.</p>\n<p>When both <code class=\"option\">-e</code> and <code class=\"option\">--exclude-extension</code> are given, the behavior is to dump just the extensions that match at least one <code class=\"option\">-e</code> switch but no <code class=\"option\">--exclude-extension</code> switches. If <code class=\"option\">--exclude-extension</code> appears without <code class=\"option\">-e</code>, then extensions matching <code class=\"option\">--exclude-extension</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">--exclude-table-data</code> option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--filter=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: <code class=\"option\">-t</code>/<code class=\"option\">--table</code>, <code class=\"option\">--table-and-children</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, and <code class=\"option\">--exclude-table-and-children</code> for tables, <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> and <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> for schemas, <code class=\"option\">--include-foreign-data</code> for data on foreign servers, <code class=\"option\">--exclude-table-data</code> and <code class=\"option\">--exclude-table-data-and-children</code> for table data, and <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> and <code class=\"option\">--exclude-extension</code> for extensions. To read from <code class=\"literal\">STDIN</code>, use <code class=\"filename\">-</code> as the filename. The <code class=\"option\">--filter</code> 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.</p>\n<p>The file lists one object pattern per row, with the following format:</p>\n<pre class=\"synopsis\">{ include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } <em class=\"replaceable\"><code>PATTERN</code></em>\n</pre>\n<p>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:</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\">\n<p><code class=\"literal\">extension</code>: extensions. This works like the <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> or <code class=\"option\">--exclude-extension</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">foreign_data</code>: data on foreign servers. This works like the <code class=\"option\">--include-foreign-data</code> option. This keyword can only be used with the <code class=\"literal\">include</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table</code>: tables. This works like the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> or <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_and_children</code>: tables including any partitions or inheritance child tables. This works like the <code class=\"option\">--table-and-children</code> or <code class=\"option\">--exclude-table-and-children</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em>. This works like the <code class=\"option\">--exclude-table-data</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data_and_children</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em> as well as any partitions or inheritance children of the table(s). This works like the <code class=\"option\">--exclude-table-data-and-children</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">schema</code>: schemas. This works like the <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> or <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> option.</p>\n</li>\n</ul>\n</div>\n<p>Lines starting with <code class=\"literal\">#</code> are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See <a class=\"xref\" href=\"/docs/devel/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> for how to perform quoting in patterns.</p>\n<p>Example files are listed below in the <a class=\"xref\" href=\"/docs/devel/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> section.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/devel/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/devel/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump <code class=\"command\">COMMENT</code> commands.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-data</code></span></dt>\n<dd>\n<p>Do not dump data.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-policies</code></span></dt>\n<dd>\n<p>Do not dump row security policies.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-schema</code></span></dt>\n<dd>\n<p>Do not dump schema (data definitions).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p>Do not dump statistics. This is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-table-access-method</code></span></dt>\n<dd>\n<p>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.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sequence-data</code></span></dt>\n<dd>\n<p>Include sequence data in the dump. This is the default behavior except when <code class=\"option\">--no-data</code>, <code class=\"option\">--schema-only</code>, or <code class=\"option\">--statistics-only</code> is specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/devel/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/devel/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.102.\u00a0Snapshot Synchronization Functions\">Table\u00a09.102</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/devel/logicaldecoding.html\" title=\"Chapter\u00a047.\u00a0Logical Decoding\">Chapter\u00a047</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics</code></span></dt>\n<dd>\n<p>Dump optimizer statistics.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics-only</code></span></dt>\n<dd>\n<p>Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with <code class=\"option\">--filter</code>. Note that if none of the extension/schema/table patterns find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">--exclude-extension</code>, <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p>When set to <code class=\"literal\">fsync</code>, which is the default, <code class=\"command\">pg_dump --format=directory</code> will recursively open and synchronize all files in the archive directory.</p>\n<p>On Linux, <code class=\"literal\">syncfs</code> may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See <a class=\"xref\" href=\"/docs/devel/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a> for information about the caveats to be aware of when using <code class=\"literal\">syncfs</code>.</p>\n<p>This option has no effect when <code class=\"option\">--no-sync</code> is used or <code class=\"option\">--format</code> is not set to <code class=\"literal\">directory</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> option, except that it also includes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/devel/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/devel/libpq-envars.html\" title=\"32.14.\u00a0Environment Variables\">Section\u00a032.14</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/devel/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the cumulative statistics system. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When options <code class=\"option\">-e</code>, <code class=\"option\">-n</code> or <code class=\"option\">-t</code> are specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected object(s) might depend upon. Therefore, there is no guarantee that the results of a dump so generated can be successfully restored by themselves into a clean database. For example, if a table whose definition includes a foreign key is specified to be restored, the table referenced by the foreign key is not automatically restored.</p>\n<p>When a dump without schema is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>When creating an archive (non-text) output file, it is advisable not to restrict the set of database objects dumped, but instead plan to apply any desired object filtering when reading the archive with <span class=\"application\">pg_restore</span>. This will preserve flexibility and possibly avoid problems at restore time; for details see the <a class=\"xref\" href=\"/docs/devel/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> documentation. In particular, dumping table data without the corresponding table definition (via <code class=\"option\">--no-schema</code> and related options) is not recommended.</p>\n<p>When <code class=\"option\">--statistics</code> is specified, <code class=\"command\">pg_dump</code> will include most optimizer statistics in the resulting dump file. This does not include all statistics, such as custom statistics added by an extension, or statistics collected by the cumulative statistics system. Therefore, it may still be useful to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/devel/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/devel/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 10 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <code class=\"literal\">two_phase = false</code>. After the initial sync, the <a class=\"link\" href=\"/docs/devel/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-TWO-PHASE\"><code class=\"literal\">two_phase</code></a> option will be automatically enabled by the subscriber if the subscription had been originally created with <code class=\"literal\">two_phase = true</code> option.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/devel/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">mytable</code>, except for table <code class=\"structname\">mytable2</code>, specify a filter file <code class=\"filename\">filter.txt</code> like:</p>\n<pre class=\"programlisting\">include table mytable*\nexclude table mytable2\n</pre>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump --filter=filter.txt mydb &gt; db.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/devel/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/devel/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/devel/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "signature": "-b --large-objects --blobs (deprecated)", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "signature": "-B --no-large-objects --no-blobs (deprecated)", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note pg_dump does not dump the extension's underlying installation files (such as shared libraries or control files). These must be available on the destination system for the restore to succeed."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump unless the directory exists and is empty."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "signature": "--exclude-extension= pattern", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "signature": "--exclude-table-and-children= pattern", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "signature": "--exclude-table-data-and-children= pattern", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "signature": "--filter= filename", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "signature": "--no-data", "description": "Do not dump data."}, {"names": ["--no-policies"], "signature": "--no-policies", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-schema"], "signature": "--no-schema", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "signature": "--no-table-access-method", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "signature": "--sequence-data", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.102 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "signature": "--statistics", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "signature": "--statistics-only", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "signature": "--table-and-children= pattern", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "6b1c1461065aa18057502ef22a697f55b0a0f1c3b804c1deb84189fe09b714d7"}}}, "snapshot": {"facts": [{"label": "Documented executable", "value": "pg_dump"}, {"label": "Executable version", "value": "18.6"}, {"label": "Reference inventory", "value": "Client applications"}, {"label": "Option definition groups", "value": "73"}], "tables": [{"key": "options", "rows": [{"summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-a --data-only"}}, {"summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-b --large-objects --blobs (deprecated)"}}, {"summary": "Exclude large objects in the dump.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-B --no-large-objects --no-blobs (deprecated)"}}, {"summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-c --clean"}}, {"summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-C --create"}}, {"summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-e pattern --extension= pattern"}}, {"summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-E encoding --encoding= encoding"}}, {"summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-f file --file= file"}}, {"summary": "Selects the format of the output. format can be one of the following:", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-F format --format= format"}}, {"summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-j njobs --jobs= njobs"}}, {"summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-n pattern --schema= pattern"}}, {"summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-N pattern --exclude-schema= pattern"}}, {"summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-O --no-owner"}}, {"summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-R --no-reconnect"}}, {"summary": "Dump only the object definitions (schema), not data or statistics.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-s --schema-only"}}, {"summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-S username --superuser= username"}}, {"summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-t pattern --table= pattern"}}, {"summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-T pattern --exclude-table= pattern"}}, {"summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-v --verbose"}}, {"summary": "Print the pg_dump version and exit.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-V --version"}}, {"summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-x --no-privileges --no-acl"}}, {"summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]"}}, {"summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--binary-upgrade"}}, {"summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--column-inserts --attribute-inserts"}}, {"summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--disable-dollar-quoting"}}, {"summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": {"url": "/docs/18/app-pgdump.html", "text": "--disable-triggers"}}, {"summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--enable-row-security"}}, {"summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-extension= pattern"}}, {"summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-table-and-children= pattern"}}, {"summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-table-data= pattern"}}, {"summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--exclude-table-data-and-children= pattern"}}, {"summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--extra-float-digits= ndigits"}}, {"summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": {"url": "/docs/18/app-pgdump.html", "text": "--filter= filename"}}, {"summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--if-exists"}}, {"summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--include-foreign-data= foreignserver"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--inserts"}}, {"summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--load-via-partition-root"}}, {"summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--lock-wait-timeout= timeout"}}, {"summary": "Do not dump COMMENT commands.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-comments"}}, {"summary": "Do not dump data.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-data"}}, {"summary": "Do not dump row security policies.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-policies"}}, {"summary": "Do not dump publications.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-publications"}}, {"summary": "Do not dump schema (data definitions).", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-schema"}}, {"summary": "Do not dump security labels.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-security-labels"}}, {"summary": "Do not dump statistics. This is the default.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-statistics"}}, {"summary": "Do not dump subscriptions.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-subscriptions"}}, {"summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-sync"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "--no-table-access-method"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "--no-tablespaces"}}, {"summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-toast-compression"}}, {"summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--no-unlogged-table-data"}}, {"summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--on-conflict-do-nothing"}}, {"summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--quote-all-identifiers"}}, {"summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--restrict-key= restrict_key"}}, {"summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--rows-per-insert= nrows"}}, {"summary": "Only dump 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 dump all sections.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--section= sectionname"}}, {"summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--sequence-data"}}, {"summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--serializable-deferrable"}}, {"summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details).", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--snapshot= snapshotname"}}, {"summary": "Dump optimizer statistics.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--statistics"}}, {"summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--statistics-only"}}, {"summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--strict-names"}}, {"summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--sync-method= method"}}, {"summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--table-and-children= pattern"}}, {"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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--use-set-session-authorization"}}, {"summary": "Show help about pg_dump command line arguments, and exit.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-? --help"}}, {"summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-d dbname --dbname= dbname"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "-h host --host= host"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "-p port --port= port"}}, {"summary": "User name to connect as.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-U username --username= username"}}, {"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": {"url": "/docs/18/app-pgdump.html", "text": "-w --no-password"}}, {"summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "-W --password"}}, {"summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": {"url": "/docs/18/app-pgdump.html", "text": "--role= rolename"}}], "title": "Documented options", "columns": [{"key": "signature", "label": "Option and arguments"}, {"key": "summary", "label": "Description"}]}, {"key": "environment", "rows": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "title": "Environment variables", "columns": [{"key": "name", "label": "Variable"}, {"key": "description", "label": "Meaning"}]}], "options": [{"names": ["-a", "--data-only"], "summary": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.", "signature": "-a --data-only", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "summary": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is.", "signature": "-b --large-objects --blobs (deprecated)", "source_url": "/docs/18/app-pgdump.html", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "summary": "Exclude large objects in the dump.", "signature": "-B --no-large-objects --no-blobs (deprecated)", "source_url": "/docs/18/app-pgdump.html", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "summary": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified.", "signature": "-c --clean", "source_url": "/docs/18/app-pgdump.html", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "summary": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it.", "signature": "-C --create", "source_url": "/docs/18/app-pgdump.html", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "summary": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.", "signature": "-e pattern --extension= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "summary": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 .", "signature": "-E encoding --encoding= encoding", "source_url": "/docs/18/app-pgdump.html", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "summary": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before.", "signature": "-f file --file= file", "source_url": "/docs/18/app-pgdump.html", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "summary": "Selects the format of the output. format can be one of the following:", "signature": "-F format --format= format", "source_url": "/docs/18/app-pgdump.html", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "summary": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.", "signature": "-j njobs --jobs= njobs", "source_url": "/docs/18/app-pgdump.html", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "summary": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-n pattern --schema= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "summary": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns.", "signature": "-N pattern --exclude-schema= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "summary": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O .", "signature": "-O --no-owner", "source_url": "/docs/18/app-pgdump.html", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "summary": "This option is obsolete but still accepted for backwards compatibility.", "signature": "-R --no-reconnect", "source_url": "/docs/18/app-pgdump.html", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "summary": "Dump only the object definitions (schema), not data or statistics.", "signature": "-s --schema-only", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "summary": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)", "signature": "-S username --superuser= username", "source_url": "/docs/18/app-pgdump.html", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "summary": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below.", "signature": "-t pattern --table= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "summary": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns.", "signature": "-T pattern --exclude-table= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "summary": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.", "signature": "-v --verbose", "source_url": "/docs/18/app-pgdump.html", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "summary": "Print the pg_dump version and exit.", "signature": "-V --version", "source_url": "/docs/18/app-pgdump.html", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "summary": "Prevent dumping of access privileges (grant/revoke commands).", "signature": "-x --no-privileges --no-acl", "source_url": "/docs/18/app-pgdump.html", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "summary": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long .", "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "source_url": "/docs/18/app-pgdump.html", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "summary": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.", "signature": "--binary-upgrade", "source_url": "/docs/18/app-pgdump.html", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "summary": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--column-inserts --attribute-inserts", "source_url": "/docs/18/app-pgdump.html", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "summary": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.", "signature": "--disable-dollar-quoting", "source_url": "/docs/18/app-pgdump.html", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "summary": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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": "--disable-triggers", "source_url": "/docs/18/app-pgdump.html", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "summary": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to.", "signature": "--enable-row-security", "source_url": "/docs/18/app-pgdump.html", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "summary": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns.", "signature": "--exclude-extension= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "summary": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-and-children= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "summary": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.", "signature": "--exclude-table-data= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "summary": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--exclude-table-data-and-children= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "summary": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.", "signature": "--extra-float-digits= ndigits", "source_url": "/docs/18/app-pgdump.html", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "summary": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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": "--filter= filename", "source_url": "/docs/18/app-pgdump.html", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "summary": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified.", "signature": "--if-exists", "source_url": "/docs/18/app-pgdump.html", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "summary": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed.", "signature": "--include-foreign-data= foreignserver", "source_url": "/docs/18/app-pgdump.html", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "summary": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower.", "signature": "--inserts", "source_url": "/docs/18/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "summary": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.", "signature": "--load-via-partition-root", "source_url": "/docs/18/app-pgdump.html", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "summary": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)", "signature": "--lock-wait-timeout= timeout", "source_url": "/docs/18/app-pgdump.html", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "summary": "Do not dump COMMENT commands.", "signature": "--no-comments", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "summary": "Do not dump data.", "signature": "--no-data", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump data."}, {"names": ["--no-policies"], "summary": "Do not dump row security policies.", "signature": "--no-policies", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "summary": "Do not dump publications.", "signature": "--no-publications", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump publications."}, {"names": ["--no-schema"], "summary": "Do not dump schema (data definitions).", "signature": "--no-schema", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "summary": "Do not dump security labels.", "signature": "--no-security-labels", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "summary": "Do not dump statistics. This is the default.", "signature": "--no-statistics", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "summary": "Do not dump subscriptions.", "signature": "--no-subscriptions", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "summary": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.", "signature": "--no-sync", "source_url": "/docs/18/app-pgdump.html", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "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": "--no-table-access-method", "source_url": "/docs/18/app-pgdump.html", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "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": "--no-tablespaces", "source_url": "/docs/18/app-pgdump.html", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "summary": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.", "signature": "--no-toast-compression", "source_url": "/docs/18/app-pgdump.html", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "summary": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.", "signature": "--no-unlogged-table-data", "source_url": "/docs/18/app-pgdump.html", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "summary": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified.", "signature": "--on-conflict-do-nothing", "source_url": "/docs/18/app-pgdump.html", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "summary": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script.", "signature": "--quote-all-identifiers", "source_url": "/docs/18/app-pgdump.html", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "summary": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump will generate a random one as needed. Keys may contain only alphanumeric characters.", "signature": "--restrict-key= restrict_key", "source_url": "/docs/18/app-pgdump.html", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "summary": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents.", "signature": "--rows-per-insert= nrows", "source_url": "/docs/18/app-pgdump.html", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "summary": "Only dump 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 dump all sections.", "signature": "--section= sectionname", "source_url": "/docs/18/app-pgdump.html", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "summary": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified.", "signature": "--sequence-data", "source_url": "/docs/18/app-pgdump.html", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "summary": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control.", "signature": "--serializable-deferrable", "source_url": "/docs/18/app-pgdump.html", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "summary": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details).", "signature": "--snapshot= snapshotname", "source_url": "/docs/18/app-pgdump.html", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "summary": "Dump optimizer statistics.", "signature": "--statistics", "source_url": "/docs/18/app-pgdump.html", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "summary": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.", "signature": "--statistics-only", "source_url": "/docs/18/app-pgdump.html", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "summary": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names .", "signature": "--strict-names", "source_url": "/docs/18/app-pgdump.html", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "summary": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory.", "signature": "--sync-method= method", "source_url": "/docs/18/app-pgdump.html", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "summary": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern .", "signature": "--table-and-children= pattern", "source_url": "/docs/18/app-pgdump.html", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges.", "signature": "--use-set-session-authorization", "source_url": "/docs/18/app-pgdump.html", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "summary": "Show help about pg_dump command line arguments, and exit.", "signature": "-? --help", "source_url": "/docs/18/app-pgdump.html", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "summary": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options.", "signature": "-d dbname --dbname= dbname", "source_url": "/docs/18/app-pgdump.html", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "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": "-h host --host= host", "source_url": "/docs/18/app-pgdump.html", "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": ["-p port", "--port= port"], "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": "-p port --port= port", "source_url": "/docs/18/app-pgdump.html", "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": ["-U username", "--username= username"], "summary": "User name to connect as.", "signature": "-U username --username= username", "source_url": "/docs/18/app-pgdump.html", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "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": "-w --no-password", "source_url": "/docs/18/app-pgdump.html", "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", "--password"], "summary": "Force pg_dump to prompt for a password before connecting to a database.", "signature": "-W --password", "source_url": "/docs/18/app-pgdump.html", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "summary": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy.", "signature": "--role= rolename", "source_url": "/docs/18/app-pgdump.html", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "related": [{"url": "/wiki/conn/?v=18", "label": "libpq connection parameters"}], "release": {"ref": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "label": "18.6", "major": "18", "channel": "stable", "manifest": {"pdf": {"A4": {"url": "/files/documentation/pdf/18/postgresql-18-A4.pdf", "bytes": 15865106, "pages": 3154, "sha256": "19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190", "built_at": "2026-09-26"}, "US": {"url": "/files/documentation/pdf/18/postgresql-18-US.pdf", "bytes": 15748059, "pages": 3328, "sha256": "facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319", "built_at": "2026-09-26"}}, "tree": "18", "index": "index.html", "major": "18", "pages": 1148, "release": "18.6", "source_url": "https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2", "svg_assets": 3, "source_mode": "en SGML built with pinned official archive", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "revision": "ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8", "evidence_kind": "English manual and source declarations", "source_sha256": "555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}, "sources": [{"url": "/docs/18/app-pgdump.html", "file": "app-pgdump.html", "label": "18.6 English manual \u00b7 app-pgdump.html", "anchor": "", "sha256": "758860baaa3462061cc6343b8d04559ec3fbc9e77c00e426f5eb8b32c863509e"}, {"url": "/docs/18/reference-client.html", "file": "reference-client.html", "label": "Client applications inventory", "anchor": "", "sha256": "68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0"}], "sections": [], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "signature": "pg_dump [ connection-option ...] [ option ...] [ dbname ]", "description": ["pg_dump \u2014 export a PostgreSQL database as an SQL script or to other formats"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}], "manual_html": "<div><div class=\"refentry\" id=\"APP-PGDUMP\">\n<div class=\"titlepage\"></div>\n<div class=\"refnamediv\">\n<h2><span class=\"refentrytitle\"><span class=\"application\">pg_dump</span></span></h2>\n<p>pg_dump \u2014 export a <span class=\"productname\">PostgreSQL</span> database as an SQL script or to other formats</p>\n</div>\n<div class=\"refsynopsisdiv\">\n<h2>Synopsis</h2>\n<div class=\"cmdsynopsis\">\n<p id=\"id-1.9.4.14.4.1\"><code class=\"command\">pg_dump</code> [<em class=\"replaceable\"><code>connection-option</code></em>...] [<em class=\"replaceable\"><code>option</code></em>...] [<em class=\"replaceable\"><code>dbname</code></em>]</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-DESCRIPTION\">\n<h2>Description</h2>\n<p><span class=\"application\">pg_dump</span> is a utility for exporting a <span class=\"productname\">PostgreSQL</span> database. It makes consistent exports even if the database is being used concurrently. <span class=\"application\">pg_dump</span> does not block other users accessing the database (readers or writers). Note, however, that except in simple cases, <span class=\"application\">pg_dump</span> is generally not the right choice for taking regular backups of production databases. See <a class=\"xref\" href=\"/docs/18/backup.html\" title=\"Chapter\u00a025.\u00a0Backup and Restore\">Chapter\u00a025</a> for further discussion.</p>\n<p><span class=\"application\">pg_dump</span> only dumps a single database. To export an entire cluster, or to export global objects that are common to all databases in a cluster (such as roles and tablespaces), use <a class=\"xref\" href=\"/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>.</p>\n<p>Dumps can be output in script or archive file formats. Script dumps are plain-text files containing the SQL commands required to reconstruct the database to the state it was in at the time it was saved. To restore from such a script, feed it to <a class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Script files can be used to reconstruct the database even on other machines and other architectures; with some modifications, even on other SQL database products.</p>\n<p>The alternative archive file formats must be used with <a class=\"xref\" href=\"/docs/18/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a> to rebuild the database. They allow <span class=\"application\">pg_restore</span> to be selective about what is restored, or even to reorder the items prior to being restored. The archive file formats are designed to be portable across architectures.</p>\n<p>When used with one of the archive file formats and combined with <span class=\"application\">pg_restore</span>, <span class=\"application\">pg_dump</span> provides a flexible archival and transfer mechanism. <span class=\"application\">pg_dump</span> can be used to export an entire database, then <span class=\"application\">pg_restore</span> can be used to examine the archive and/or select which parts of the database are to be restored. The most flexible output file formats are the <span class=\"quote\">\u201c<span class=\"quote\">custom</span>\u201d</span> format (<code class=\"option\">-Fc</code>) and the <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format (<code class=\"option\">-Fd</code>). They allow for selection and reordering of all archived items, support parallel restoration, and are compressed by default. The <span class=\"quote\">\u201c<span class=\"quote\">directory</span>\u201d</span> format is the only format that supports parallel dumps.</p>\n<p>While running <span class=\"application\">pg_dump</span>, one should examine the output for any warnings (printed on standard error), especially in light of the limitations listed below.</p>\n<div class=\"warning\">\n<h3 class=\"title\">Warning</h3>\n<p>Restoring 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 <span class=\"application\">pg_restore</span>'s <code class=\"option\">--file</code> option. Note that the client running the dump and restore need not trust the source or destination superusers.</p>\n</div>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-OPTIONS\">\n<h2>Options</h2>\n<p>The following command-line options control the content and format of the output.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><em class=\"replaceable\"><code>dbname</code></em></span></dt>\n<dd>\n<p>Specifies the name of the database to be dumped. If this is not specified, the environment variable <code class=\"envar\">PGDATABASE</code> is used. If that is not set, the user name specified for the connection is used.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-a</code><br></span><span class=\"term\"><code class=\"option\">--data-only</code></span></dt>\n<dd>\n<p>Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped.</p>\n<p>This option is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-b</code><br></span><span class=\"term\"><code class=\"option\">--large-objects</code><br></span><span class=\"term\"><code class=\"option\">--blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Include large objects in the dump. This is the default behavior except when <code class=\"option\">--schema</code>, <code class=\"option\">--table</code>, <code class=\"option\">--schema-only</code>, <code class=\"option\">--statistics-only</code>, or <code class=\"option\">--no-data</code> is specified. The <code class=\"option\">-b</code> switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when <code class=\"option\">--data-only</code> is used, but not when <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code> is.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-B</code><br></span><span class=\"term\"><code class=\"option\">--no-large-objects</code><br></span><span class=\"term\"><code class=\"option\">--no-blobs</code> (deprecated)</span></dt>\n<dd>\n<p>Exclude large objects in the dump.</p>\n<p>When both <code class=\"option\">-b</code> and <code class=\"option\">-B</code> are given, the behavior is to output large objects, when data is being dumped, see the <code class=\"option\">-b</code> documentation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-c</code><br></span><span class=\"term\"><code class=\"option\">--clean</code></span></dt>\n<dd>\n<p>Output commands to <code class=\"command\">DROP</code> all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless <code class=\"option\">--if-exists</code> is also specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-C</code><br></span><span class=\"term\"><code class=\"option\">--create</code></span></dt>\n<dd>\n<p>Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If <code class=\"option\">--clean</code> is also specified, the script drops and recreates the target database before reconnecting to it.</p>\n<p>With <code class=\"option\">--create</code>, the output also includes the database's comment if any, and any configuration variable settings that are specific to this database, that is, any <code class=\"command\">ALTER DATABASE ... SET ...</code> and <code class=\"command\">ALTER ROLE ... IN DATABASE ... SET ...</code> commands that mention this database. Access privileges for the database itself are also dumped, unless <code class=\"option\">--no-acl</code> is specified.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-e <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only extensions matching <em class=\"replaceable\"><code>pattern</code></em>. When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple <code class=\"option\">-e</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards.</p>\n<p>Any configuration relation registered by <code class=\"function\">pg_extension_config_dump</code> is included in the dump if its extension is specified by <code class=\"option\">--extension</code>.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-e</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-E <em class=\"replaceable\"><code>encoding</code></em></code><br></span><span class=\"term\"><code class=\"option\">--encoding=<em class=\"replaceable\"><code>encoding</code></em></code></span></dt>\n<dd>\n<p>Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the <code class=\"envar\">PGCLIENTENCODING</code> environment variable to the desired dump encoding.) The supported encodings are described in <a class=\"xref\" href=\"/docs/18/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED\" title=\"23.3.1.\u00a0Supported Character Sets\">Section\u00a023.3.1</a>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-f <em class=\"replaceable\"><code>file</code></em></code><br></span><span class=\"term\"><code class=\"option\">--file=<em class=\"replaceable\"><code>file</code></em></code></span></dt>\n<dd>\n<p>Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by <code class=\"command\">pg_dump</code> and must not exist before.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-F <em class=\"replaceable\"><code>format</code></em></code><br></span><span class=\"term\"><code class=\"option\">--format=<em class=\"replaceable\"><code>format</code></em></code></span></dt>\n<dd>\n<p>Selects the format of the output. <em class=\"replaceable\"><code>format</code></em> can be one of the following:</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"literal\">p</code><br></span><span class=\"term\"><code class=\"literal\">plain</code></span></dt>\n<dd>\n<p>Output a plain-text SQL script file (the default).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">c</code><br></span><span class=\"term\"><code class=\"literal\">custom</code></span></dt>\n<dd>\n<p>Output a custom-format archive suitable for input into <span class=\"application\">pg_restore</span>. Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">d</code><br></span><span class=\"term\"><code class=\"literal\">directory</code></span></dt>\n<dd>\n<p>Output a directory-format archive suitable for input into <span class=\"application\">pg_restore</span>. This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that <span class=\"application\">pg_restore</span> can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span> tools. This format is compressed by default using <code class=\"literal\">gzip</code> and also supports parallel dumps.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"literal\">t</code><br></span><span class=\"term\"><code class=\"literal\">tar</code></span></dt>\n<dd>\n<p>Output a <code class=\"command\">tar</code>-format archive suitable for input into <span class=\"application\">pg_restore</span>. The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore.</p>\n</dd>\n</dl>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-j <em class=\"replaceable\"><code>njobs</code></em></code><br></span><span class=\"term\"><code class=\"option\">--jobs=<em class=\"replaceable\"><code>njobs</code></em></code></span></dt>\n<dd>\n<p>Run the dump in parallel by dumping <em class=\"replaceable\"><code>njobs</code></em> tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time.</p>\n<p><span class=\"application\">pg_dump</span> will open <em class=\"replaceable\"><code>njobs</code></em> + 1 connections to the database, so make sure your <a class=\"xref\" href=\"/docs/18/runtime-config-connection.html#GUC-MAX-CONNECTIONS\">max_connections</a> setting is high enough to accommodate all connections.</p>\n<p>Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the <span class=\"application\">pg_dump</span> leader process requests shared locks (<a class=\"link\" href=\"/docs/18/explicit-locking.html#LOCKING-TABLES\" title=\"13.3.1.\u00a0Table-Level Locks\">ACCESS SHARE</a>) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the <span class=\"application\">pg_dump</span> worker process requests another shared lock using the <code class=\"literal\">NOWAIT</code> option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so <span class=\"application\">pg_dump</span> has no choice but to abort the dump.</p>\n<p>To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in <span class=\"productname\">PostgreSQL</span> 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. <code class=\"command\">pg_dump -j</code> uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-n <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only schemas matching <em class=\"replaceable\"><code>pattern</code></em>; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple <code class=\"option\">-n</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-n</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Non-schema objects such as large objects are not dumped when <code class=\"option\">-n</code> is specified. You can add large objects back to the dump with the <code class=\"option\">--large-objects</code> switch.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-N <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-schema=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any schemas matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-n</code>. <code class=\"option\">-N</code> can be given more than once to exclude schemas matching any of several patterns.</p>\n<p>When both <code class=\"option\">-n</code> and <code class=\"option\">-N</code> are given, the behavior is to dump just the schemas that match at least one <code class=\"option\">-n</code> switch but no <code class=\"option\">-N</code> switches. If <code class=\"option\">-N</code> appears without <code class=\"option\">-n</code>, then schemas matching <code class=\"option\">-N</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-O</code><br></span><span class=\"term\"><code class=\"option\">--no-owner</code></span></dt>\n<dd>\n<p>Do not output commands to set ownership of objects to match the original database. By default, <span class=\"application\">pg_dump</span> issues <code class=\"command\">ALTER OWNER</code> or <code class=\"command\">SET SESSION AUTHORIZATION</code> statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify <code class=\"option\">-O</code>.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-R</code><br></span><span class=\"term\"><code class=\"option\">--no-reconnect</code></span></dt>\n<dd>\n<p>This option is obsolete but still accepted for backwards compatibility.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-s</code><br></span><span class=\"term\"><code class=\"option\">--schema-only</code></span></dt>\n<dd>\n<p>Dump only the object definitions (schema), not data or statistics.</p>\n<p>This option cannot be used with <code class=\"option\">--data-only</code> or <code class=\"option\">--statistics-only</code>. It is similar to, but for historical reasons not identical to, specifying <code class=\"option\">--section=pre-data --section=post-data</code>.</p>\n<p>(Do not confuse this with the <code class=\"option\">--schema</code> option, which uses the word <span class=\"quote\">\u201c<span class=\"quote\">schema</span>\u201d</span> in a different meaning.)</p>\n<p>To exclude table data for only a subset of tables in the database, see <code class=\"option\">--exclude-table-data</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-S <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--superuser=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>Specify the superuser user name to use when disabling triggers. This is relevant only if <code class=\"option\">--disable-triggers</code> is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-t <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Dump only tables with names matching <em class=\"replaceable\"><code>pattern</code></em>. Multiple tables can be selected by writing multiple <code class=\"option\">-t</code> switches. The <em class=\"replaceable\"><code>pattern</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below.</p>\n<p>As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with <code class=\"option\">--include-foreign-data</code>.</p>\n<p>The <code class=\"option\">-n</code> and <code class=\"option\">-N</code> switches have no effect when <code class=\"option\">-t</code> is used, because tables selected by <code class=\"option\">-t</code> will be dumped regardless of those switches, and non-table objects will not be dumped.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">-t</code> is specified, <span class=\"application\">pg_dump</span> makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-T <em class=\"replaceable\"><code>pattern</code></em></code><br></span><span class=\"term\"><code class=\"option\">--exclude-table=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">-T</code> can be given more than once to exclude tables matching any of several patterns.</p>\n<p>When both <code class=\"option\">-t</code> and <code class=\"option\">-T</code> are given, the behavior is to dump just the tables that match at least one <code class=\"option\">-t</code> switch but no <code class=\"option\">-T</code> switches. If <code class=\"option\">-T</code> appears without <code class=\"option\">-t</code>, then tables matching <code class=\"option\">-T</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-v</code><br></span><span class=\"term\"><code class=\"option\">--verbose</code></span></dt>\n<dd>\n<p>Specifies verbose mode. This will cause <span class=\"application\">pg_dump</span> to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-V</code><br></span><span class=\"term\"><code class=\"option\">--version</code></span></dt>\n<dd>\n<p>Print the <span class=\"application\">pg_dump</span> version and exit.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-x</code><br></span><span class=\"term\"><code class=\"option\">--no-privileges</code><br></span><span class=\"term\"><code class=\"option\">--no-acl</code></span></dt>\n<dd>\n<p>Prevent dumping of access privileges (grant/revoke commands).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">-Z <em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]<br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>level</code></em></code><br></span><span class=\"term\"><code class=\"option\">--compress=<em class=\"replaceable\"><code>method</code></em></code>[:<em class=\"replaceable\"><code>detail</code></em>]</span></dt>\n<dd>\n<p>Specify the compression method and/or the compression level to use. The compression method can be set to <code class=\"literal\">gzip</code>, <code class=\"literal\">lz4</code>, <code class=\"literal\">zstd</code>, or <code class=\"literal\">none</code> for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form <code class=\"literal\">keyword</code> or <code class=\"literal\">keyword=value</code>. Currently, the supported keywords are <code class=\"literal\">level</code> and <code class=\"literal\">long</code>.</p>\n<p>If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, <code class=\"literal\">gzip</code> compression will be used if the level is greater than <code class=\"literal\">0</code>, and no compression will be used if the level is <code class=\"literal\">0</code>.</p>\n<p>For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using <code class=\"literal\">gzip</code> at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through <span class=\"application\">gzip</span>, <span class=\"application\">lz4</span>, or <span class=\"application\">zstd</span>; but the default is not to compress. With zstd compression, <code class=\"literal\">long</code> mode may improve the compression ratio, at the cost of increased memory use.</p>\n<p>The tar archive format currently does not support compression at all.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--binary-upgrade</code></span></dt>\n<dd>\n<p>This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--column-inserts</code><br></span><span class=\"term\"><code class=\"option\">--attribute-inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands with explicit column names (<code class=\"literal\">INSERT INTO <em class=\"replaceable\"><code>table</code></em> (<em class=\"replaceable\"><code>column</code></em>, ...) VALUES ...</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-dollar-quoting</code></span></dt>\n<dd>\n<p>This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--disable-triggers</code></span></dt>\n<dd>\n<p>This option is relevant only when creating a dump that includes data but does not include schema. It instructs <span class=\"application\">pg_dump</span> to include 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.</p>\n<p>Presently, the commands emitted for <code class=\"option\">--disable-triggers</code> must be done as superuser. So, you should also specify a superuser name with <code class=\"option\">-S</code>, or preferably be careful to start the resulting script as a superuser.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--enable-row-security</code></span></dt>\n<dd>\n<p>This option is relevant only when dumping the contents of a table which has row security. By default, <span class=\"application\">pg_dump</span> will set <a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs <span class=\"application\">pg_dump</span> to set <a class=\"xref\" href=\"/docs/18/runtime-config-client.html#GUC-ROW-SECURITY\">row_security</a> to on instead, allowing the user to dump the parts of the contents of the table that they have access to.</p>\n<p>Note that if you use this option currently, you probably also want the dump be in <code class=\"command\">INSERT</code> format, as the <code class=\"command\">COPY FROM</code> during restore does not support row security.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-extension=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump any extensions matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-e</code>. <code class=\"option\">--exclude-extension</code> can be given more than once to exclude extensions matching any of several patterns.</p>\n<p>When both <code class=\"option\">-e</code> and <code class=\"option\">--exclude-extension</code> are given, the behavior is to dump just the extensions that match at least one <code class=\"option\">-e</code> switch but no <code class=\"option\">--exclude-extension</code> switches. If <code class=\"option\">--exclude-extension</code> appears without <code class=\"option\">-e</code>, then extensions matching <code class=\"option\">--exclude-extension</code> are excluded from what is otherwise a normal dump.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>Do not dump data for any tables matching <em class=\"replaceable\"><code>pattern</code></em>. The pattern is interpreted according to the same rules as for <code class=\"option\">-t</code>. <code class=\"option\">--exclude-table-data</code> can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it.</p>\n<p>To exclude data for all tables in the database, see <code class=\"option\">--schema-only</code> or <code class=\"option\">--statistics-only</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--exclude-table-data-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">--exclude-table-data</code> option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--extra-float-digits=<em class=\"replaceable\"><code>ndigits</code></em></code></span></dt>\n<dd>\n<p>Use the specified value of <code class=\"option\">extra_float_digits</code> when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--filter=<em class=\"replaceable\"><code>filename</code></em></code></span></dt>\n<dd>\n<p>Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: <code class=\"option\">-t</code>/<code class=\"option\">--table</code>, <code class=\"option\">--table-and-children</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, and <code class=\"option\">--exclude-table-and-children</code> for tables, <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> and <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> for schemas, <code class=\"option\">--include-foreign-data</code> for data on foreign servers, <code class=\"option\">--exclude-table-data</code> and <code class=\"option\">--exclude-table-data-and-children</code> for table data, and <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> and <code class=\"option\">--exclude-extension</code> for extensions. To read from <code class=\"literal\">STDIN</code>, use <code class=\"filename\">-</code> as the filename. The <code class=\"option\">--filter</code> 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.</p>\n<p>The file lists one object pattern per row, with the following format:</p>\n<pre class=\"synopsis\">{ include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } <em class=\"replaceable\"><code>PATTERN</code></em>\n</pre>\n<p>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:</p>\n<div class=\"itemizedlist\">\n<ul class=\"itemizedlist\">\n<li class=\"listitem\">\n<p><code class=\"literal\">extension</code>: extensions. This works like the <code class=\"option\">-e</code>/<code class=\"option\">--extension</code> or <code class=\"option\">--exclude-extension</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">foreign_data</code>: data on foreign servers. This works like the <code class=\"option\">--include-foreign-data</code> option. This keyword can only be used with the <code class=\"literal\">include</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table</code>: tables. This works like the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> or <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_and_children</code>: tables including any partitions or inheritance child tables. This works like the <code class=\"option\">--table-and-children</code> or <code class=\"option\">--exclude-table-and-children</code> option.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em>. This works like the <code class=\"option\">--exclude-table-data</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">table_data_and_children</code>: table data of any tables matching <em class=\"replaceable\"><code>pattern</code></em> as well as any partitions or inheritance children of the table(s). This works like the <code class=\"option\">--exclude-table-data-and-children</code> option. This keyword can only be used with the <code class=\"literal\">exclude</code> keyword.</p>\n</li>\n<li class=\"listitem\">\n<p><code class=\"literal\">schema</code>: schemas. This works like the <code class=\"option\">-n</code>/<code class=\"option\">--schema</code> or <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code> option.</p>\n</li>\n</ul>\n</div>\n<p>Lines starting with <code class=\"literal\">#</code> are considered comments and ignored. Comments can be placed after an object pattern row as well. Blank lines are also ignored. See <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a> for how to perform quoting in patterns.</p>\n<p>Example files are listed below in the <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> section.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--if-exists</code></span></dt>\n<dd>\n<p>Use <code class=\"literal\">DROP ... IF EXISTS</code> commands to drop objects in <code class=\"option\">--clean</code> mode. This suppresses <span class=\"quote\">\u201c<span class=\"quote\">does not exist</span>\u201d</span> errors that might otherwise be reported. This option is not valid unless <code class=\"option\">--clean</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--include-foreign-data=<em class=\"replaceable\"><code>foreignserver</code></em></code></span></dt>\n<dd>\n<p>Dump the data for any foreign table with a foreign server matching <em class=\"replaceable\"><code>foreignserver</code></em> pattern. Multiple foreign servers can be selected by writing multiple <code class=\"option\">--include-foreign-data</code> switches. Also, the <em class=\"replaceable\"><code>foreignserver</code></em> parameter is interpreted as a pattern according to the same rules used by <span class=\"application\">psql</span>'s <code class=\"literal\">\\d</code> commands (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see <a class=\"xref\" href=\"/docs/18/app-pgdump.html#PG-DUMP-EXAMPLES\" title=\"Examples\">Examples</a> below. The only exception is that an empty pattern is disallowed.</p>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>Using wildcards in <code class=\"option\">--include-foreign-data</code> may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner.</p>\n</div>\n<div class=\"note\">\n<h3 class=\"title\">Note</h3>\n<p>When <code class=\"option\">--include-foreign-data</code> is specified, <span class=\"application\">pg_dump</span> does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored.</p>\n</div>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--inserts</code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non-<span class=\"productname\">PostgreSQL</span> databases. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The <code class=\"option\">--column-inserts</code> option is safe against column order changes, though even slower.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--load-via-partition-root</code></span></dt>\n<dd>\n<p>When dumping data for a table partition, make the <code class=\"command\">COPY</code> or <code class=\"command\">INSERT</code> statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--lock-wait-timeout=<em class=\"replaceable\"><code>timeout</code></em></code></span></dt>\n<dd>\n<p>Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified <em class=\"replaceable\"><code>timeout</code></em>. The timeout may be specified in any of the formats accepted by <code class=\"command\">SET statement_timeout</code>. (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-comments</code></span></dt>\n<dd>\n<p>Do not dump <code class=\"command\">COMMENT</code> commands.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-data</code></span></dt>\n<dd>\n<p>Do not dump data.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-policies</code></span></dt>\n<dd>\n<p>Do not dump row security policies.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-publications</code></span></dt>\n<dd>\n<p>Do not dump publications.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-schema</code></span></dt>\n<dd>\n<p>Do not dump schema (data definitions).</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-security-labels</code></span></dt>\n<dd>\n<p>Do not dump security labels.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-statistics</code></span></dt>\n<dd>\n<p>Do not dump statistics. This is the default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-subscriptions</code></span></dt>\n<dd>\n<p>Do not dump subscriptions.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-sync</code></span></dt>\n<dd>\n<p>By default, <code class=\"command\">pg_dump</code> will wait for all files to be written safely to disk. This option causes <code class=\"command\">pg_dump</code> to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-table-access-method</code></span></dt>\n<dd>\n<p>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.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-tablespaces</code></span></dt>\n<dd>\n<p>Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.</p>\n<p>This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call <code class=\"command\">pg_restore</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-toast-compression</code></span></dt>\n<dd>\n<p>Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--no-unlogged-table-data</code></span></dt>\n<dd>\n<p>Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--on-conflict-do-nothing</code></span></dt>\n<dd>\n<p>Add <code class=\"literal\">ON CONFLICT DO NOTHING</code> to <code class=\"command\">INSERT</code> commands. This option is not valid unless <code class=\"option\">--inserts</code>, <code class=\"option\">--column-inserts</code> or <code class=\"option\">--rows-per-insert</code> is also specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--quote-all-identifiers</code></span></dt>\n<dd>\n<p>Force quoting of all identifiers. This option is recommended when dumping a database from a server whose <span class=\"productname\">PostgreSQL</span> major version is different from <span class=\"application\">pg_dump</span>'s, or when the output is intended to be loaded into a server of a different major version. By default, <span class=\"application\">pg_dump</span> quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using <code class=\"option\">--quote-all-identifiers</code> prevents such issues, at the price of a harder-to-read dump script.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--restrict-key=<em class=\"replaceable\"><code>restrict_key</code></em></code></span></dt>\n<dd>\n<p>Use the provided string as the <span class=\"application\">psql</span> <code class=\"command\">\\restrict</code> key in the dump output. This can only be specified for plain-text dumps, i.e., when <code class=\"option\">--format</code> is set to <code class=\"literal\">plain</code> or the <code class=\"option\">--format</code> option is omitted. If no restrict key is specified, <span class=\"application\">pg_dump</span> will generate a random one as needed. Keys may contain only alphanumeric characters.</p>\n<p>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 <span class=\"application\">psql</span> with the dump output.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--rows-per-insert=<em class=\"replaceable\"><code>nrows</code></em></code></span></dt>\n<dd>\n<p>Dump data as <code class=\"command\">INSERT</code> commands (rather than <code class=\"command\">COPY</code>). Controls the maximum number of rows per <code class=\"command\">INSERT</code> command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic <code class=\"command\">INSERT</code> to be lost, rather than the entire table contents.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--section=<em class=\"replaceable\"><code>sectionname</code></em></code></span></dt>\n<dd>\n<p>Only dump the named section. The section name can be <code class=\"option\">pre-data</code>, <code class=\"option\">data</code>, or <code class=\"option\">post-data</code>. This option can be specified more than once to select multiple sections. The default is to dump all sections.</p>\n<p>The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sequence-data</code></span></dt>\n<dd>\n<p>Include sequence data in the dump. This is the default behavior except when <code class=\"option\">--no-data</code>, <code class=\"option\">--schema-only</code>, or <code class=\"option\">--statistics-only</code> is specified.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--serializable-deferrable</code></span></dt>\n<dd>\n<p>Use a <code class=\"literal\">serializable</code> transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a <code class=\"literal\">serialization_failure</code>. See <a class=\"xref\" href=\"/docs/18/mvcc.html\" title=\"Chapter\u00a013.\u00a0Concurrency Control\">Chapter\u00a013</a> for more information about transaction isolation and concurrency control.</p>\n<p>This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing.</p>\n<p>This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--snapshot=<em class=\"replaceable\"><code>snapshotname</code></em></code></span></dt>\n<dd>\n<p>Use the specified synchronized snapshot when making a dump of the database (see <a class=\"xref\" href=\"/docs/18/functions-admin.html#FUNCTIONS-SNAPSHOT-SYNCHRONIZATION-TABLE\" title=\"Table\u00a09.100.\u00a0Snapshot Synchronization Functions\">Table\u00a09.100</a> for more details).</p>\n<p>This option is useful when needing to synchronize the dump with a logical replication slot (see <a class=\"xref\" href=\"/docs/18/logicaldecoding.html\" title=\"Chapter\u00a047.\u00a0Logical Decoding\">Chapter\u00a047</a>) or with a concurrent session.</p>\n<p>In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics</code></span></dt>\n<dd>\n<p>Dump optimizer statistics.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--statistics-only</code></span></dt>\n<dd>\n<p>Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--strict-names</code></span></dt>\n<dd>\n<p>Require that each extension (<code class=\"option\">-e</code>/<code class=\"option\">--extension</code>), schema (<code class=\"option\">-n</code>/<code class=\"option\">--schema</code>) and table (<code class=\"option\">-t</code>/<code class=\"option\">--table</code>) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with <code class=\"option\">--filter</code>. Note that if none of the extension/schema/table patterns find matches, <span class=\"application\">pg_dump</span> will generate an error even without <code class=\"option\">--strict-names</code>.</p>\n<p>This option has no effect on <code class=\"option\">--exclude-extension</code>, <code class=\"option\">-N</code>/<code class=\"option\">--exclude-schema</code>, <code class=\"option\">-T</code>/<code class=\"option\">--exclude-table</code>, or <code class=\"option\">--exclude-table-data</code>. An exclude pattern failing to match any objects is not considered an error.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--sync-method=<em class=\"replaceable\"><code>method</code></em></code></span></dt>\n<dd>\n<p>When set to <code class=\"literal\">fsync</code>, which is the default, <code class=\"command\">pg_dump --format=directory</code> will recursively open and synchronize all files in the archive directory.</p>\n<p>On Linux, <code class=\"literal\">syncfs</code> may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See <a class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\">recovery_init_sync_method</a> for information about the caveats to be aware of when using <code class=\"literal\">syncfs</code>.</p>\n<p>This option has no effect when <code class=\"option\">--no-sync</code> is used or <code class=\"option\">--format</code> is not set to <code class=\"literal\">directory</code>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--table-and-children=<em class=\"replaceable\"><code>pattern</code></em></code></span></dt>\n<dd>\n<p>This is the same as the <code class=\"option\">-t</code>/<code class=\"option\">--table</code> option, except that it also includes any partitions or inheritance child tables of the table(s) matching the <em class=\"replaceable\"><code>pattern</code></em>.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--use-set-session-authorization</code></span></dt>\n<dd>\n<p>Output SQL-standard <code class=\"command\">SET SESSION AUTHORIZATION</code> commands instead of <code class=\"command\">ALTER OWNER</code> 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. Also, a dump using <code class=\"command\">SET SESSION AUTHORIZATION</code> will certainly require superuser privileges to restore correctly, whereas <code class=\"command\">ALTER OWNER</code> requires lesser privileges.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-?</code><br></span><span class=\"term\"><code class=\"option\">--help</code></span></dt>\n<dd>\n<p>Show help about <span class=\"application\">pg_dump</span> command line arguments, and exit.</p>\n</dd>\n</dl>\n</div>\n<p>The following command-line options control the database connection parameters.</p>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"option\">-d <em class=\"replaceable\"><code>dbname</code></em></code><br></span><span class=\"term\"><code class=\"option\">--dbname=<em class=\"replaceable\"><code>dbname</code></em></code></span></dt>\n<dd>\n<p>Specifies the name of the database to connect to. This is equivalent to specifying <em class=\"replaceable\"><code>dbname</code></em> as the first non-option argument on the command line. The <em class=\"replaceable\"><code>dbname</code></em> can be a <a class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1.\u00a0Connection Strings\">connection string</a>. If so, connection string parameters will override any conflicting command line options.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-h <em class=\"replaceable\"><code>host</code></em></code><br></span><span class=\"term\"><code class=\"option\">--host=<em class=\"replaceable\"><code>host</code></em></code></span></dt>\n<dd>\n<p>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 <code class=\"envar\">PGHOST</code> environment variable, if set, else a Unix domain socket connection is attempted.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-p <em class=\"replaceable\"><code>port</code></em></code><br></span><span class=\"term\"><code class=\"option\">--port=<em class=\"replaceable\"><code>port</code></em></code></span></dt>\n<dd>\n<p>Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the <code class=\"envar\">PGPORT</code> environment variable, if set, or a compiled-in default.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-U <em class=\"replaceable\"><code>username</code></em></code><br></span><span class=\"term\"><code class=\"option\">--username=<em class=\"replaceable\"><code>username</code></em></code></span></dt>\n<dd>\n<p>User name to connect as.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-w</code><br></span><span class=\"term\"><code class=\"option\">--no-password</code></span></dt>\n<dd>\n<p>Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <code class=\"filename\">.pgpass</code> 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.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">-W</code><br></span><span class=\"term\"><code class=\"option\">--password</code></span></dt>\n<dd>\n<p>Force <span class=\"application\">pg_dump</span> to prompt for a password before connecting to a database.</p>\n<p>This option is never essential, since <span class=\"application\">pg_dump</span> will automatically prompt for a password if the server demands password authentication. However, <span class=\"application\">pg_dump</span> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <code class=\"option\">-W</code> to avoid the extra connection attempt.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"option\">--role=<em class=\"replaceable\"><code>rolename</code></em></code></span></dt>\n<dd>\n<p>Specifies a role name to be used to create the dump. This option causes <span class=\"application\">pg_dump</span> to issue a <code class=\"command\">SET ROLE</code> <em class=\"replaceable\"><code>rolename</code></em> command after connecting to the database. It is useful when the authenticated user (specified by <code class=\"option\">-U</code>) lacks privileges needed by <span class=\"application\">pg_dump</span>, 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 dumps to be made without violating the policy.</p>\n</dd>\n</dl>\n</div>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.7\">\n<h2>Environment</h2>\n<div class=\"variablelist\">\n<dl class=\"variablelist\">\n<dt><span class=\"term\"><code class=\"envar\">PGDATABASE</code><br></span><span class=\"term\"><code class=\"envar\">PGHOST</code><br></span><span class=\"term\"><code class=\"envar\">PGOPTIONS</code><br></span><span class=\"term\"><code class=\"envar\">PGPORT</code><br></span><span class=\"term\"><code class=\"envar\">PGUSER</code></span></dt>\n<dd>\n<p>Default connection parameters.</p>\n</dd>\n<dt><span class=\"term\"><code class=\"envar\">PG_COLOR</code></span></dt>\n<dd>\n<p>Specifies whether to use color in diagnostic messages. Possible values are <code class=\"literal\">always</code>, <code class=\"literal\">auto</code> and <code class=\"literal\">never</code>.</p>\n</dd>\n</dl>\n</div>\n<p>This utility, like most other <span class=\"productname\">PostgreSQL</span> utilities, also uses the environment variables supported by <span class=\"application\">libpq</span> (see <a class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15.\u00a0Environment Variables\">Section\u00a032.15</a>).</p>\n</div>\n<div class=\"refsect1\" id=\"APP-PGDUMP-DIAGNOSTICS\">\n<h2>Diagnostics</h2>\n<p><span class=\"application\">pg_dump</span> internally executes <code class=\"command\">SELECT</code> statements. If you have problems running <span class=\"application\">pg_dump</span>, make sure you are able to select information from the database using, for example, <a class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a>. Also, any default connection settings and environment variables used by the <span class=\"application\">libpq</span> front-end library will apply.</p>\n<p>The database activity of <span class=\"application\">pg_dump</span> is normally collected by the cumulative statistics system. If this is undesirable, you can set parameter <code class=\"varname\">track_counts</code> to false via <code class=\"envar\">PGOPTIONS</code> or the <code class=\"literal\">ALTER USER</code> command.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-NOTES\">\n<h2>Notes</h2>\n<p>If your database cluster has any local additions to the <code class=\"literal\">template1</code> database, be careful to restore the output of <span class=\"application\">pg_dump</span> 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 <code class=\"literal\">template0</code> not <code class=\"literal\">template1</code>, for example:</p>\n<pre class=\"programlisting\">CREATE DATABASE foo WITH TEMPLATE template0;\n</pre>\n<p>When a dump without schema is chosen and the option <code class=\"option\">--disable-triggers</code> is used, <span class=\"application\">pg_dump</span> emits commands to disable triggers on user tables before inserting the data, and then 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.</p>\n<p>When <code class=\"option\">--statistics</code> is specified, <code class=\"command\">pg_dump</code> will include most optimizer statistics in the resulting dump file. This does not include all statistics, such as those created explicitly with <a class=\"xref\" href=\"/docs/18/sql-createstatistics.html\" title=\"CREATE STATISTICS\"><span class=\"refentrytitle\">CREATE STATISTICS</span></a>, custom statistics added by an extension, or statistics collected by the cumulative statistics system. Therefore, it may still be useful to run <code class=\"command\">ANALYZE</code> after restoring from a dump file to ensure optimal performance; see <a class=\"xref\" href=\"/docs/18/routine-vacuuming.html#VACUUM-FOR-STATISTICS\" title=\"24.1.3.\u00a0Updating Planner Statistics\">Section\u00a024.1.3</a> and <a class=\"xref\" href=\"/docs/18/routine-vacuuming.html#AUTOVACUUM\" title=\"24.1.6.\u00a0The Autovacuum Daemon\">Section\u00a024.1.6</a> for more information.</p>\n<p>Because <span class=\"application\">pg_dump</span> is used to transfer data to newer versions of <span class=\"productname\">PostgreSQL</span>, the output of <span class=\"application\">pg_dump</span> can be expected to load into <span class=\"productname\">PostgreSQL</span> server versions newer than <span class=\"application\">pg_dump</span>'s version. <span class=\"application\">pg_dump</span> can also dump from <span class=\"productname\">PostgreSQL</span> servers older than its own version. (Currently, servers back to version 9.2 are supported.) However, <span class=\"application\">pg_dump</span> cannot dump from <span class=\"productname\">PostgreSQL</span> servers newer than its own major version; it will refuse to even try, rather than risk making an invalid dump. Also, it is not guaranteed that <span class=\"application\">pg_dump</span>'s output can be loaded into a server of an older major version \u2014 not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. Use of the <code class=\"option\">--quote-all-identifiers</code> option is recommended in cross-version cases, as it can prevent problems arising from varying reserved-word lists in different <span class=\"productname\">PostgreSQL</span> versions.</p>\n<p>When dumping logical replication subscriptions, <span class=\"application\">pg_dump</span> will generate <code class=\"command\">CREATE SUBSCRIPTION</code> commands that use the <code class=\"literal\">connect = false</code> option, so that restoring the subscription does not make remote connections for creating a replication slot or for initial table copy. That way, the dump can be restored without requiring network access to the remote servers. It is then up to the user to reactivate the subscriptions in a suitable way. If the involved hosts have changed, the connection information might have to be changed. It might also be appropriate to truncate the target tables before initiating a new full table copy. If users intend to copy initial data during refresh they must create the slot with <code class=\"literal\">two_phase = false</code>. After the initial sync, the <a class=\"link\" href=\"/docs/18/sql-createsubscription.html#SQL-CREATESUBSCRIPTION-PARAMS-WITH-TWO-PHASE\"><code class=\"literal\">two_phase</code></a> option will be automatically enabled by the subscriber if the subscription had been originally created with <code class=\"literal\">two_phase = true</code> option.</p>\n<p>It is generally recommended to use the <code class=\"option\">-X</code> (<code class=\"option\">--no-psqlrc</code>) option when restoring a database from a plain-text <span class=\"application\">pg_dump</span> script to ensure a clean restore process and prevent potential conflicts with non-default <span class=\"application\">psql</span> configurations.</p>\n</div>\n<div class=\"refsect1\" id=\"PG-DUMP-EXAMPLES\">\n<h2>Examples</h2>\n<p>To dump a database called <code class=\"literal\">mydb</code> into an SQL-script file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump mydb &gt; db.sql</code></strong>\n</pre>\n<p>To reload such a script into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>psql -X -d newdb -f db.sql</code></strong>\n</pre>\n<p>To dump a database into a custom-format archive file:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fc mydb &gt; db.dump</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -f dumpdir</code></strong>\n</pre>\n<p>To dump a database into a directory-format archive in parallel with 5 worker jobs:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -Fd mydb -j 5 -f dumpdir</code></strong>\n</pre>\n<p>To reload an archive file into a (freshly created) database named <code class=\"literal\">newdb</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d newdb db.dump</code></strong>\n</pre>\n<p>To reload an archive file into the same database it was dumped from, discarding the current contents of that database:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_restore -d postgres --clean --create db.dump</code></strong>\n</pre>\n<p>To dump a single table named <code class=\"literal\">mytab</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t mytab mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">emp</code> in the <code class=\"literal\">detroit</code> schema, except for the table named <code class=\"literal\">employee_log</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all schemas whose names start with <code class=\"literal\">east</code> or <code class=\"literal\">west</code> and end in <code class=\"literal\">gsm</code>, excluding any schemas whose names contain the word <code class=\"literal\">test</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>The same, using regular expression notation to consolidate the switches:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -n '(east|west)*gsm' -N '*test*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To dump all database objects except for tables whose names begin with <code class=\"literal\">ts_</code>:</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -T 'ts_*' mydb &gt; db.sql</code></strong>\n</pre>\n<p>To specify an upper-case or mixed-case name in <code class=\"option\">-t</code> and related switches, you need to double-quote the name; else it will be folded to lower case (see <a class=\"xref\" href=\"/docs/18/app-psql.html#APP-PSQL-PATTERNS\" title=\"Patterns\">Patterns</a>). But double quotes are special to the shell, so in turn they must be quoted. Thus, to dump a single table with a mixed-case name, you need something like</p>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump -t \"\\\"MixedCaseName\\\"\" mydb &gt; mytab.sql</code></strong>\n</pre>\n<p>To dump all tables whose names start with <code class=\"literal\">mytable</code>, except for table <code class=\"literal\">mytable2</code>, specify a filter file <code class=\"filename\">filter.txt</code> like:</p>\n<pre class=\"programlisting\">include table mytable*\nexclude table mytable2\n</pre>\n<pre class=\"screen\"><code class=\"prompt\">$</code> <strong class=\"userinput\"><code>pg_dump --filter=filter.txt mydb &gt; db.sql</code></strong>\n</pre>\n</div>\n<div class=\"refsect1\" id=\"id-1.9.4.14.11\">\n<h2>See Also</h2><span class=\"simplelist\"><a class=\"xref\" href=\"/docs/18/app-pg-dumpall.html\" title=\"pg_dumpall\"><span class=\"refentrytitle\"><span class=\"application\">pg_dumpall</span></span></a>, <a class=\"xref\" href=\"/docs/18/app-pgrestore.html\" title=\"pg_restore\"><span class=\"refentrytitle\"><span class=\"application\">pg_restore</span></span></a>, <a class=\"xref\" href=\"/docs/18/app-psql.html\" title=\"psql\"><span class=\"refentrytitle\"><span class=\"application\">psql</span></span></a></span>\n</div>\n</div></div>", "manual_path": "app-pgdump.html", "comparison_data": {"options": [{"names": ["-a", "--data-only"], "signature": "-a --data-only", "description": "Dump only the data, not the schema (data definitions) or statistics. Table data, large objects, and sequence values are dumped. This option is similar to, but for historical reasons not identical to, specifying --section=data ."}, {"names": ["-b", "--large-objects", "--blobs"], "signature": "-b --large-objects --blobs (deprecated)", "description": "Include large objects in the dump. This is the default behavior except when --schema , --table , --schema-only , --statistics-only , or --no-data is specified. The -b switch is therefore only useful to add large objects to dumps where a specific schema or table has been requested. Note that large objects are considered data and therefore will be included when --data-only is used, but not when --schema-only or --statistics-only is."}, {"names": ["-B", "--no-large-objects", "--no-blobs"], "signature": "-B --no-large-objects --no-blobs (deprecated)", "description": "Exclude large objects in the dump. When both -b and -B are given, the behavior is to output large objects, when data is being dumped, see the -b documentation."}, {"names": ["-c", "--clean"], "signature": "-c --clean", "description": "Output commands to DROP all the dumped database objects prior to outputting the commands for creating them. This option is useful when the restore is to overwrite an existing database. If any of the objects do not exist in the destination database, ignorable error messages will be reported during restore, unless --if-exists is also specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-C", "--create"], "signature": "-C --create", "description": "Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.) If --clean is also specified, the script drops and recreates the target database before reconnecting to it. With --create , the output also includes 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 dumped, unless --no-acl is specified. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-e pattern", "--extension= pattern"], "signature": "-e pattern --extension= pattern", "description": "Dump only extensions matching pattern . When this option is not specified, all non-system extensions in the target database will be dumped. Multiple extensions can be selected by writing multiple -e switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple extensions can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards. Any configuration relation registered by pg_extension_config_dump is included in the dump if its extension is specified by --extension . Note When -e is specified, pg_dump makes no attempt to dump any other database objects that the selected extension(s) might depend upon. Therefore, there is no guarantee that the results of a specific-extension dump can be successfully restored by themselves into a clean database."}, {"names": ["-E encoding", "--encoding= encoding"], "signature": "-E encoding --encoding= encoding", "description": "Create the dump in the specified character set encoding. By default, the dump is created in the database encoding. (Another way to get the same result is to set the PGCLIENTENCODING environment variable to the desired dump encoding.) The supported encodings are described in Section 23.3.1 ."}, {"names": ["-f file", "--file= file"], "signature": "-f file --file= file", "description": "Send output to the specified file. This parameter can be omitted for file based output formats, in which case the standard output is used. It must be given for the directory output format however, where it specifies the target directory instead of a file. In this case the directory is created by pg_dump and must not exist before."}, {"names": ["-F format", "--format= format"], "signature": "-F format --format= format", "description": "Selects the format of the output. format can be one of the following: p plain Output a plain-text SQL script file (the default). c custom Output a custom-format archive suitable for input into pg_restore . Together with the directory output format, this is the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default. d directory Output a directory-format archive suitable for input into pg_restore . This will create a directory with one file for each table and large object being dumped, plus a so-called Table of Contents file describing the dumped objects in a machine-readable format that pg_restore can read. A directory format archive can be manipulated with standard Unix tools; for example, files in an uncompressed archive can be compressed with the gzip , lz4 , or zstd tools. This format is compressed by default using gzip and also supports parallel dumps. t tar Output a tar -format archive suitable for input into pg_restore . The tar format is compatible with the directory format: extracting a tar-format archive produces a valid directory-format archive. However, the tar format does not support compression. Also, when using tar format the relative order of table data items cannot be changed during restore."}, {"names": ["-j njobs", "--jobs= njobs"], "signature": "-j njobs --jobs= njobs", "description": "Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup."}, {"names": ["-n pattern", "--schema= pattern"], "signature": "-n pattern --schema= pattern", "description": "Dump only schemas matching pattern ; this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped. Multiple schemas can be selected by writing multiple -n switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple schemas can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. Note When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. Note Non-schema objects such as large objects are not dumped when -n is specified. You can add large objects back to the dump with the --large-objects switch."}, {"names": ["-N pattern", "--exclude-schema= pattern"], "signature": "-N pattern --exclude-schema= pattern", "description": "Do not dump any schemas matching pattern . The pattern is interpreted according to the same rules as for -n . -N can be given more than once to exclude schemas matching any of several patterns. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n , then schemas matching -N are excluded from what is otherwise a normal dump."}, {"names": ["-O", "--no-owner"], "signature": "-O --no-owner", "description": "Do not output commands to set ownership of objects to match the original database. By default, pg_dump issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created database objects. These statements will fail when the script is run unless it is started by a superuser (or the same user that owns all of the objects in the script). To make a script that can be restored by any user, but will give that user ownership of all the objects, specify -O . This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["-R", "--no-reconnect"], "signature": "-R --no-reconnect", "description": "This option is obsolete but still accepted for backwards compatibility."}, {"names": ["-s", "--schema-only"], "signature": "-s --schema-only", "description": "Dump only the object definitions (schema), not data or statistics. 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 . (Do not confuse this with the --schema option, which uses the word \u201c schema \u201d in a different meaning.) To exclude table data for only a subset of tables in the database, see --exclude-table-data ."}, {"names": ["-S username", "--superuser= username"], "signature": "-S username --superuser= username", "description": "Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used. (Usually, it's better to leave this out, and instead start the resulting script as superuser.)"}, {"names": ["-t pattern", "--table= pattern"], "signature": "-t pattern --table= pattern", "description": "Dump only tables with names matching pattern . Multiple tables can be selected by writing multiple -t switches. The pattern parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple tables can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. As well as tables, this option can be used to dump the definition of matching views, materialized views, foreign tables, and sequences. It will not dump the contents of views or materialized views, and the contents of foreign tables will only be dumped if the corresponding foreign server is specified with --include-foreign-data . The -n and -N switches have no effect when -t is used, because tables selected by -t will be dumped regardless of those switches, and non-table objects will not be dumped. Note When -t is specified, pg_dump makes no attempt to dump any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that the results of a specific-table dump can be successfully restored by themselves into a clean database."}, {"names": ["-T pattern", "--exclude-table= pattern"], "signature": "-T pattern --exclude-table= pattern", "description": "Do not dump any tables matching pattern . The pattern is interpreted according to the same rules as for -t . -T can be given more than once to exclude tables matching any of several patterns. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches. If -T appears without -t , then tables matching -T are excluded from what is otherwise a normal dump."}, {"names": ["-v", "--verbose"], "signature": "-v --verbose", "description": "Specifies verbose mode. This will cause pg_dump to output detailed object comments and start/stop times to the dump file, and progress messages to standard error. Repeating the option causes additional debug-level messages to appear on standard error."}, {"names": ["-V", "--version"], "signature": "-V --version", "description": "Print the pg_dump version and exit."}, {"names": ["-x", "--no-privileges", "--no-acl"], "signature": "-x --no-privileges --no-acl", "description": "Prevent dumping of access privileges (grant/revoke commands)."}, {"names": ["-Z level", "-Z method", "--compress= level", "--compress= method"], "signature": "-Z level -Z method [: detail ] --compress= level --compress= method [: detail ]", "description": "Specify the compression method and/or the compression level to use. The compression method can be set to gzip , lz4 , zstd , or none for no compression. A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level and long . If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0 , and no compression will be used if the level is 0 . For the custom and directory archive formats, this specifies compression of individual table-data segments, and the default is to compress using gzip at a moderate level. For plain text output, setting a nonzero compression level causes the entire output file to be compressed, as though it had been fed through gzip , lz4 , or zstd ; but the default is not to compress. With zstd compression, long mode may improve the compression ratio, at the cost of increased memory use. The tar archive format currently does not support compression at all."}, {"names": ["--binary-upgrade"], "signature": "--binary-upgrade", "description": "This option is for use by in-place upgrade utilities. Its use for other purposes is not recommended or supported. The behavior of the option may change in future releases without notice."}, {"names": ["--column-inserts", "--attribute-inserts"], "signature": "--column-inserts --attribute-inserts", "description": "Dump data as INSERT commands with explicit column names ( INSERT INTO table ( column , ...) VALUES ... ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--disable-dollar-quoting"], "signature": "--disable-dollar-quoting", "description": "This option disables the use of dollar quoting for function bodies, and forces them to be quoted using SQL standard string syntax."}, {"names": ["--disable-triggers"], "signature": "--disable-triggers", "description": "This option is relevant only when creating a dump that includes data but does not include schema. It instructs pg_dump to include 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 be careful to start the resulting script as a superuser. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--enable-row-security"], "signature": "--enable-row-security", "description": "This option is relevant only when dumping the contents of a table which has row security. By default, pg_dump will set row_security to off, to ensure that all data is dumped from the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_dump to set row_security to on instead, allowing the user to dump the parts of the contents of the table that they have access to. Note that if you use this option currently, you probably also want the dump be in INSERT format, as the COPY FROM during restore does not support row security."}, {"names": ["--exclude-extension= pattern"], "signature": "--exclude-extension= pattern", "description": "Do not dump any extensions matching pattern . The pattern is interpreted according to the same rules as for -e . --exclude-extension can be given more than once to exclude extensions matching any of several patterns. When both -e and --exclude-extension are given, the behavior is to dump just the extensions that match at least one -e switch but no --exclude-extension switches. If --exclude-extension appears without -e , then extensions matching --exclude-extension are excluded from what is otherwise a normal dump."}, {"names": ["--exclude-table-and-children= pattern"], "signature": "--exclude-table-and-children= pattern", "description": "This is the same as the -T / --exclude-table option, except that it also excludes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--exclude-table-data= pattern"], "signature": "--exclude-table-data= pattern", "description": "Do not dump data for any tables matching pattern . The pattern is interpreted according to the same rules as for -t . --exclude-table-data can be given more than once to exclude tables matching any of several patterns. This option is useful when you need the definition of a particular table even though you do not need the data in it. To exclude data for all tables in the database, see --schema-only or --statistics-only ."}, {"names": ["--exclude-table-data-and-children= pattern"], "signature": "--exclude-table-data-and-children= pattern", "description": "This is the same as the --exclude-table-data option, except that it also excludes data of any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--extra-float-digits= ndigits"], "signature": "--extra-float-digits= ndigits", "description": "Use the specified value of extra_float_digits when dumping floating-point data, instead of the maximum available precision. Routine dumps made for backup purposes should not use this option."}, {"names": ["--filter= filename"], "signature": "--filter= filename", "description": "Specify a filename from which to read patterns for objects to include or exclude from the dump. The patterns are interpreted according to the same rules as the corresponding options: -t / --table , --table-and-children , -T / --exclude-table , and --exclude-table-and-children for tables, -n / --schema and -N / --exclude-schema for schemas, --include-foreign-data for data on foreign servers, --exclude-table-data and --exclude-table-data-and-children for table data, and -e / --extension and --exclude-extension for extensions. 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 object pattern per row, with the following format: { include | exclude } { extension | foreign_data | table | table_and_children | table_data | table_data_and_children | schema } 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: extension : extensions. This works like the -e / --extension or --exclude-extension option. foreign_data : data on foreign servers. This works like the --include-foreign-data option. This keyword can only be used with the include keyword. table : tables. This works like the -t / --table or -T / --exclude-table option. table_and_children : tables including any partitions or inheritance child tables. This works like the --table-and-children or --exclude-table-and-children option. table_data : table data of any tables matching pattern . This works like the --exclude-table-data option. This keyword can only be used with the exclude keyword. table_data_and_children : table data of any tables matching pattern as well as any partitions or inheritance children of the table(s). This works like the --exclude-table-data-and-children option. This keyword can only be used with the exclude keyword. schema : schemas. This works like the -n / --schema or -N / --exclude-schema option. 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. Example files are listed below in the Examples section."}, {"names": ["--if-exists"], "signature": "--if-exists", "description": "Use DROP ... IF EXISTS commands to drop objects in --clean mode. This suppresses \u201c does not exist \u201d errors that might otherwise be reported. This option is not valid unless --clean is also specified."}, {"names": ["--include-foreign-data= foreignserver"], "signature": "--include-foreign-data= foreignserver", "description": "Dump the data for any foreign table with a foreign server matching foreignserver pattern. Multiple foreign servers can be selected by writing multiple --include-foreign-data switches. Also, the foreignserver parameter is interpreted as a pattern according to the same rules used by psql 's \\d commands (see Patterns ), so multiple foreign servers can also be selected by writing wildcard characters in the pattern. When using wildcards, be careful to quote the pattern if needed to prevent the shell from expanding the wildcards; see Examples below. The only exception is that an empty pattern is disallowed. Note Using wildcards in --include-foreign-data may result in access to unexpected foreign servers. Also, to use this option securely, make sure that the named server must have a trusted owner. Note When --include-foreign-data is specified, pg_dump does not check that the foreign table is writable. Therefore, there is no guarantee that the results of a foreign table dump can be successfully restored."}, {"names": ["--inserts"], "signature": "--inserts", "description": "Dump data as INSERT commands (rather than COPY ). This will make restoration very slow; it is mainly useful for making dumps that can be loaded into non- PostgreSQL databases. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents. Note that the restore might fail altogether if you have rearranged column order. The --column-inserts option is safe against column order changes, though even slower."}, {"names": ["--load-via-partition-root"], "signature": "--load-via-partition-root", "description": "When dumping data for a table partition, make the COPY or INSERT statements target the root of the partitioning hierarchy that contains it, rather than the partition itself. This causes the appropriate partition to be re-determined for each row when the data is loaded. This may be useful when restoring data on a server where rows do not always fall into the same partitions as they did on the original server. That could happen, for example, if the partitioning column is of type text and the two systems have different definitions of the collation used to sort the partitioning column."}, {"names": ["--lock-wait-timeout= timeout"], "signature": "--lock-wait-timeout= timeout", "description": "Do not wait forever to acquire shared table locks at the beginning of the dump. Instead fail if unable to lock a table within the specified timeout . The timeout may be specified in any of the formats accepted by SET statement_timeout . (Allowed formats vary depending on the server version you are dumping from, but an integer number of milliseconds is accepted by all versions.)"}, {"names": ["--no-comments"], "signature": "--no-comments", "description": "Do not dump COMMENT commands."}, {"names": ["--no-data"], "signature": "--no-data", "description": "Do not dump data."}, {"names": ["--no-policies"], "signature": "--no-policies", "description": "Do not dump row security policies."}, {"names": ["--no-publications"], "signature": "--no-publications", "description": "Do not dump publications."}, {"names": ["--no-schema"], "signature": "--no-schema", "description": "Do not dump schema (data definitions)."}, {"names": ["--no-security-labels"], "signature": "--no-security-labels", "description": "Do not dump security labels."}, {"names": ["--no-statistics"], "signature": "--no-statistics", "description": "Do not dump statistics. This is the default."}, {"names": ["--no-subscriptions"], "signature": "--no-subscriptions", "description": "Do not dump subscriptions."}, {"names": ["--no-sync"], "signature": "--no-sync", "description": "By default, pg_dump will wait for all files to be written safely to disk. This option causes pg_dump to return without waiting, which is faster, but means that a subsequent operating system crash can leave the dump corrupt. Generally, this option is useful for testing but should not be used when dumping data from production installation."}, {"names": ["--no-table-access-method"], "signature": "--no-table-access-method", "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. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-tablespaces"], "signature": "--no-tablespaces", "description": "Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore. This option is ignored when emitting an archive (non-text) output file. For the archive formats, you can specify the option when you call pg_restore ."}, {"names": ["--no-toast-compression"], "signature": "--no-toast-compression", "description": "Do not output commands to set TOAST compression methods. With this option, all columns will be restored with the default compression setting."}, {"names": ["--no-unlogged-table-data"], "signature": "--no-unlogged-table-data", "description": "Do not dump the contents of unlogged tables and sequences. This option has no effect on whether or not the table and sequence definitions (schema) are dumped; it only suppresses dumping the table and sequence data. Data in unlogged tables and sequences is always excluded when dumping from a standby server."}, {"names": ["--on-conflict-do-nothing"], "signature": "--on-conflict-do-nothing", "description": "Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts , --column-inserts or --rows-per-insert is also specified."}, {"names": ["--quote-all-identifiers"], "signature": "--quote-all-identifiers", "description": "Force quoting of all identifiers. This option is recommended when dumping a database from a server whose PostgreSQL major version is different from pg_dump 's, or when the output is intended to be loaded into a server of a different major version. By default, pg_dump quotes only identifiers that are reserved words in its own major version. This sometimes results in compatibility issues when dealing with servers of other versions that may have slightly different sets of reserved words. Using --quote-all-identifiers prevents such issues, at the price of a harder-to-read dump script."}, {"names": ["--restrict-key= restrict_key"], "signature": "--restrict-key= restrict_key", "description": "Use the provided string as the psql \\restrict key in the dump output. This can only be specified for plain-text dumps, i.e., when --format is set to plain or the --format option is omitted. If no restrict key is specified, pg_dump 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": ["--rows-per-insert= nrows"], "signature": "--rows-per-insert= nrows", "description": "Dump data as INSERT commands (rather than COPY ). Controls the maximum number of rows per INSERT command. The value specified must be a number greater than zero. Any error during restoring will cause only rows that are part of the problematic INSERT to be lost, rather than the entire table contents."}, {"names": ["--section= sectionname"], "signature": "--section= sectionname", "description": "Only dump 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 dump all sections. The data section contains actual table data, large-object contents, sequence values, and statistics for tables, materialized views, and foreign tables. Post-data items include definitions of indexes, triggers, rules, statistics for indexes, and constraints other than validated check and not-null constraints. Pre-data items include all other data definition items."}, {"names": ["--sequence-data"], "signature": "--sequence-data", "description": "Include sequence data in the dump. This is the default behavior except when --no-data , --schema-only , or --statistics-only is specified."}, {"names": ["--serializable-deferrable"], "signature": "--serializable-deferrable", "description": "Use a serializable transaction for the dump, to ensure that the snapshot used is consistent with later database states; but do this by waiting for a point in the transaction stream at which no anomalies can be present, so that there isn't a risk of the dump failing or causing other transactions to roll back with a serialization_failure . See Chapter 13 for more information about transaction isolation and concurrency control. This option is not beneficial for a dump which is intended only for disaster recovery. It could be useful for a dump used to load a copy of the database for reporting or other read-only load sharing while the original database continues to be updated. Without it the dump may reflect a state which is not consistent with any serial execution of the transactions eventually committed. For example, if batch processing techniques are used, a batch may show as closed in the dump without all of the items which are in the batch appearing. This option will make no difference if there are no read-write transactions active when pg_dump is started. If read-write transactions are active, the start of the dump may be delayed for an indeterminate length of time. Once running, performance with or without the switch is the same."}, {"names": ["--snapshot= snapshotname"], "signature": "--snapshot= snapshotname", "description": "Use the specified synchronized snapshot when making a dump of the database (see Table 9.100 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot."}, {"names": ["--statistics"], "signature": "--statistics", "description": "Dump optimizer statistics."}, {"names": ["--statistics-only"], "signature": "--statistics-only", "description": "Dump only the statistics, not the schema (data definitions) or data. Optimizer statistics for tables, materialized views, foreign tables, and indexes are dumped."}, {"names": ["--strict-names"], "signature": "--strict-names", "description": "Require that each extension ( -e / --extension ), schema ( -n / --schema ) and table ( -t / --table ) pattern match at least one extension/schema/table in the database to be dumped. This also applies to filters used with --filter . Note that if none of the extension/schema/table patterns find matches, pg_dump will generate an error even without --strict-names . This option has no effect on --exclude-extension , -N / --exclude-schema , -T / --exclude-table , or --exclude-table-data . An exclude pattern failing to match any objects is not considered an error."}, {"names": ["--sync-method= method"], "signature": "--sync-method= method", "description": "When set to fsync , which is the default, pg_dump --format=directory will recursively open and synchronize all files in the archive directory. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the archive directory. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used or --format is not set to directory ."}, {"names": ["--table-and-children= pattern"], "signature": "--table-and-children= pattern", "description": "This is the same as the -t / --table option, except that it also includes any partitions or inheritance child tables of the table(s) matching the pattern ."}, {"names": ["--use-set-session-authorization"], "signature": "--use-set-session-authorization", "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. Also, a dump using SET SESSION AUTHORIZATION will certainly require superuser privileges to restore correctly, whereas ALTER OWNER requires lesser privileges."}, {"names": ["-?", "--help"], "signature": "-? --help", "description": "Show help about pg_dump command line arguments, and exit."}, {"names": ["-d dbname", "--dbname= dbname"], "signature": "-d dbname --dbname= dbname", "description": "Specifies the name of the database to connect to. This is equivalent to specifying dbname as the first non-option argument on the command line. The dbname can be a connection string . If so, connection string parameters will override any conflicting command line options."}, {"names": ["-h host", "--host= host"], "signature": "-h host --host= host", "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": ["-p port", "--port= port"], "signature": "-p port --port= port", "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": ["-U username", "--username= username"], "signature": "-U username --username= username", "description": "User name to connect as."}, {"names": ["-w", "--no-password"], "signature": "-w --no-password", "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", "--password"], "signature": "-W --password", "description": "Force pg_dump to prompt for a password before connecting to a database. This option is never essential, since pg_dump will automatically prompt for a password if the server demands password authentication. However, pg_dump 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": ["--role= rolename"], "signature": "--role= rolename", "description": "Specifies a role name to be used to create the dump. This option causes pg_dump 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_dump , 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 dumps to be made without violating the policy."}], "synopsis": ["pg_dump [ connection-option ...] [ option ...] [ dbname ]"], "environment": [{"name": "PGDATABASE PGHOST PGOPTIONS PGPORT PGUSER", "description": "Default connection parameters."}, {"name": "PG_COLOR", "description": "Specifies whether to use color in diagnostic messages. Possible values are always , auto and never ."}]}, "comparison_hash": "e4fc1961ca5ae638ffddf6b82d9336086bc97a70b652b15a5b41f476128da561"}, "comparison": {"left": "19", "right": "20", "status": "changed", "diff": "--- PostgreSQL 19\n+++ PostgreSQL 20\n@@ -85,7 +85,7 @@\n       \"signature\": \"-F format --format= format\"\n     },\n     {\n-      \"description\": \"Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump. To perform a parallel dump, the database server needs to support synchronized snapshots, a feature that was introduced in PostgreSQL 9.2 for primary servers and 10 for standbys. With this feature, database clients can ensure they see the same data set even though they use different connections. pg_dump -j uses multiple database connections; it connects to the database once with the leader process and once again for each worker job. Without the synchronized snapshot feature, the different worker jobs wouldn't be guaranteed to see the same data in each connection, which could lead to an inconsistent backup.\",\n+      \"description\": \"Run the dump in parallel by dumping njobs tables simultaneously. This option may reduce the time needed to perform the dump but it also increases the load on the database server. You can only use this option with the directory output format because this is the only output format where multiple processes can write their data at the same time. pg_dump will open njobs + 1 connections to the database, so make sure your max_connections setting is high enough to accommodate all connections. Requesting exclusive locks on database objects while running a parallel dump could cause the dump to fail. The reason is that the pg_dump leader process requests shared locks ( ACCESS SHARE ) on the objects that the worker processes are going to dump later in order to make sure that nobody deletes them and makes them go away while the dump is running. If another client then requests an exclusive lock on a table, that lock will not be granted but will be queued waiting for the shared lock of the leader process to be released. Consequently any other access to the table will not be granted either and will queue after the exclusive lock request. This includes the worker process trying to dump the table. Without any precautions this would be a classic deadlock situation. To detect this conflict, the pg_dump worker process requests another shared lock using the NOWAIT option. If the worker process is not granted this shared lock, somebody else must have requested an exclusive lock in the meantime and there is no way to continue with the dump, so pg_dump has no choice but to abort the dump.\",\n       \"names\": [\n         \"-j njobs\",\n         \"--jobs= njobs\"\n@@ -445,7 +445,7 @@\n       \"signature\": \"--serializable-deferrable\"\n     },\n     {\n-      \"description\": \"Use the specified synchronized snapshot when making a dump of the database (see Table 9.101 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.\",\n+      \"description\": \"Use the specified synchronized snapshot when making a dump of the database (see Table 9.102 for more details). This option is useful when needing to synchronize the dump with a logical replication slot (see Chapter 47 ) or with a concurrent session. In the case of a parallel dump, the snapshot name defined by this option is used rather than taking a new snapshot.\",\n       \"names\": [\n         \"--snapshot= snapshotname\"\n       ],"}}