Postgresql学习笔记之——SQL转储工具pg_dump、pg_restore工具参数解析

pg_dump 和 pg_restore 工具的使用示例参考:

一、pg_dump工具

pg_dump 命令的格式如下:

pg_dump [ connection-option... ] [option...] [dbname]

1.pg_dump 连接参数

1)-h host 或 --host=host
指定数据库服务运行的主机IP或主机名称。

2)-p port 或 --port=port
执行数据库的监听端口号,默认5432。

3)-U username 或 --username=username
指定要链接的数据库用户名。

4)-w 或 --no-password
从不提示密码。远程导出加此参数会导致命令错误,此选项一般用在数据库服务本地服务器导出时不指定密码。

5)-W 或 --password
强制 pg_dump 在连接一个数据库时提示密码。此参数选项可以不指定,因为如果服务器要求密码验证,pg_dump会自动提示密码输入,不指定时会浪费一个连接试图找出服务器是否需要面,指定时可避免额外的链接尝试。

6)–role=rolename
该选项会导致 pg_dump 在连接数据库时发送一个 SELECT ROLE rolename 命令。相当于切换到了指定的角色上,当已验证的用户缺少 pg_dump 运行需要的权限时,可以使用该选项指定的有相应权限的角色上。

7)dbname
指定连接的数据库名称,实际上也是要备份的数据库。

2.pg_dump 导出指定参数

1)-a 或 --data-only
此选项针对纯文本格式,是输出数据,不输出数据定义的SQL语句。

2)-b 或 --blobs
在转储中是否包含大对象。除非指定了选择性转储的选项 --schema、–table、–schema-only开关,否则默认是会转储大对象。

3)-B 或 --no-blobs
转储时不导出大对象,当 -b 和 -B 同时指定时,默认是 -b 导出大对象。

4)-c 或 --clean
此选项针对纯文本,指定输出的脚本中是否生成清理该数据库对象的语句(如 drop table命令)

5)-C 或 --create
此选项针对纯文本。指定脚本中是否输出一条 create database 语句和连接到该数据库的语句。一般在备份的源数据库与恢复的目标数据库名称一致时,才指定这个参数。

6)-E encoding 或 --encoding=encoding
指定字符集编码创建转储文件。默认转储时一句数据库编码创建的。如果不指定此参数,可以通过设置环境变量 $PGCLIENTENCODING 达到同样目的。

7)-f file 或 --file=file
输出到指定的文件中。如果没有指定此参数,则输出到标准输出中。

8)-F format 或 --format=format
选择输出的格式。format可以是p、c、t或d。
① p 是 plain 的意思,为纯文本SQL脚本文件的格式。默认值。
② c 是 custom 的意思,以一个适合 pg_restore 使用的自定义格式输出并归档。最灵活的输出格式。默认压缩。
③ t 是 tar 的意思,以一个适合输入 pg_restore的tar格式输出并归档。该输出格式允许手动选择并在恢复时重排归档项的顺序,但这个是有限制的,比如,表数据项的相关顺序在恢复时不能更改。同时,tar格式不支持压缩,并且对独立表的大小限制为 8GB。
④ p 输出适合输入到pg_restore的目录格式存档。这将为每个被转储的表和blob创建一个目录,其中包含一个文件,以及一个所谓的内容表文件,该文件以机器可读的格式描述转储的对象,pg_restore可以读取该格式。目录格式存档可以使用标准的Unix工具进行操作;例如,未压缩的归档文件中的文件可以使用gzip工具进行压缩。这种格式在默认情况下是压缩的,并且还支持并行转储。

9)-j njobs 或 –jobs=njobs
同时转储 njobs 个表来运行并行转储。这个选项缩减了转储的时间,但是它也增加了数据库服务器上的负载。你只能和目录输出格式一起使用这个选项,因为这是唯一一种让多个进程能在同一时间写其数据的输出格式。

pg_dump将打开njobs + 1 个到该数据库的连接,因此确保你的max_connections设置足够高以容纳所有的连接。

在运行一次并行转储时请求数据库对象上的排他锁可能导致转储失败。其原因是,pg_dump主控进程会在工作者进程将要稍后转储的对象上请求共享锁,以便确保在转储运行时不会有人删除它们并让它们出错。如果另一个客户端接着请求一个表上的排他锁,那个锁将不会被授予但是会被排入队列等待主控进程的共享锁被释放。因此,任何其他对该表的访问将不会被授予或者将排在排他锁请求之后。这包括尝试转储该表的工作者进程。如果没有任何防范措施,这可能会是一种经典的死锁情况。要检测这种冲突,pg_dump工作者进程使用NOWAIT选项请求另一个共享锁。 如果该工作者进程没有被授予这个共享锁,其他某人必定已经在同时请求了一个排他锁并且没有办法继续转储,因此pg_dump除了中止转储之外别无选择。

对于一个一致的备份,数据库服务器需要支持同步的快照,在PostgreSQL 9.2中引入了一种特性。有了这种特性,即便数据库客户端使用不同的连接,也可以保证他们看到相同的数据集。pg_dump -j使用多个数据库连接,它用主控进程连接到数据一次,并且为每一个工作者任务再一次连接数据库。如果没有同步快照特征,在每一个连接中不同的工作者任务将不能被保证看到相同的数据,这可能导致一个不一致的备份。

如果你希望运行一个 9.2 之前服务器的并行转储,你需要确保数据库内容从主控进程连接到数据库一直到最后一个工作者任务连接到数据库之间不会改变。做这些最简单的方法是在开始备份之前停止任何访问数据库的数据修改进程(DDL 以及 DML)。当对一个 9.2 之前的PostgreSQL服务器运行pg_dump -j时,你还需要指定–no-synchronized-snapshots参数。

10)-n schema 或 --schema=schema
只转储匹配schema的模式内容,包括模式本身以及其中包含的对象。如果没有声明这个选项,所有目标数据库中的非系统模式都会被转储出来。可以使用多个 -n 选项指定多个模式转储。

PS:如果指定了 -n ,那么 pg_dump 将不会转储指定的模式中所依赖的其他数据库对象,因此无法保证转储的内容一定能够在另一个干净的数据库中成功恢复。非模式对象,比如大对象,不会再指定 -n 时被转出出来。可以使用 --blobs 明确要求转储大对象。

11)-N schema 或 --exclude-schema=schema
不转储参数指定里的 schema 模式中内容。匹配规则与 -n 完全相同,可以指定多个 -N 匹配多个模式。

如果同时指定了 -n 和 -N ,那么就只转储 -n 指定模式,不转储 -N 指定的模式。

12)-o 或 --oids
参数指定是否为每个表都输出对象标识(OID)。当应用中需要OID字段(比如用于外检约束)时,可以使用这个选项。

13)-O 或 --no-owner
此参数针对纯文本格式。表示不把转储的对象的所有权设置为对应源数据库中的owner。pg_dump 默认发出 ALTER OWNER 或 SET SESSION AUTHORAZATION 语句来设置创建的数据库对象的所有者。如果这些脚本将来没有被超级用户(或拥有脚本中全部对象的用户)运行,会导致恢复失败, -O 选项就是为了让该脚本可以被任何用户使用。

14)-s 或 --schema-only
只输出对象定义(模式),不输出数据,此选项用于备份表结构或在另一个数据库上创建相同结构的表。

15)-S username 或 --superuser=username
此参数指定关闭触发器时需要用到的超级用户名。它只在使用了 --disable-triggers 时才有作用。

16)-t table 或 --table=table
此参数指定只转储出匹配table的表、视图、序列。可以使用多个 -t 选项匹配多个表。使用 -t 后,-n 和 -N 选项就失效了。

PS:如果指定了 -t,那么 pg_dump 不会转储指定的表所依赖的其他数据库对象。

17)-T table 或 --exclude-table=table
此参数指定的表不转储,可以指定多个 -T 来排除不需要导出的表。

18)-v 或 --verbose
导出执行时打印详细的信息。

19)-V 或 --version
输出 pg_dump 工具版本。

20)-x 或 --no-privileges 或 --no-acl
禁止转储访问权限(grant、revoke 命令)。

21)-Z 0…9 或 --compress=0…9
指定转储文件压缩的级别,0表示不压缩。对于自定义归档格式,该参数指定压缩的单个表数据段,并且默认用中等水平压缩。对于纯文本输出,设置一个非零的压缩级别会导致全部输出文件被压缩。默认不压缩。tar归档格式不支持压缩。

22)–binary-upgrade
此选项专门用于升级工具。

23)–inserts
此参数会像INSERT命令一样转储数据。默认使用 COPY 命令的格式转储数据,使用此选项将使恢复非常慢。这个选项主要用于把数据加载到非 Postgresql 数据库中。该选项为表数据每一行生成一个单独的 INSERT 命令,当数据库恢复时遇到一行错误时,它只会导致错误的这一行数据丢失,而不是全部数据。

PS:使用 --inserts 选项导出后进行恢复时,如果目标表列的顺序和源表列的顺序不一样,恢复可能会完全失败,这时应该使用 --column-inserts 选项

24)–column-inserts 或 --attribute-inserts
此参数会像有显式列名的 INSERT 命令一样转储数据(INSERT INTO table (column,…) VALUES (…,…,…) ),这样的恢复会很慢,主要用于将转储文件加载到非 Postgresql 数据库中。

25)–disable-dollar-quoting
此选项用于关闭使用美元符界定函数体。强制函数体内容用SQL标准的字符串语法的引号包围。

26)–disable-triggers
此选项针对纯文本格式。它告诉 pg_dump 在恢复数据时,临时关闭目标表上触发器的命令。如果表上有参照完整性检查或其他触发器,且恢复数据时不需要重载它们,就使用此选项。

PS:目前,为 --disable-trigger 发出的命令必须作为超级用户执行。因此,还应该使用-S指定超级用户名,或者最好小心地以超级用户的身份启动结果脚本。

27)–enable-row-security
此选项只有在转储具有行安全性的表的内容时才有用。默认情况下, pg_dump将把 row_security设置为 off 来确保从该表中转储出所有的数据。如果用户不具有足够能绕过行安全性的特权,那么会抛出 一个错误这个参数指示pg_dump将 row_security设置为 on,允许用户只转储该表中 它们能够访问到的部分内容。

28)–exclude-table-data=table
此选项表示不转储匹配table模式的任何表中的数据。–exclude-table-data可以被给定多次来排除匹配多个模式的表。应用于当你需要一个特定表的定义但不想要其中的数据时。

29)–if-exists
在清理数据库对象时使用条件命令(即添加IF EXISTS子句)。 只有同时指定了–clean时,这个选项才有效。

30) --lock-wait-timeout=timeout
不在转储开始时永远等待获取共享表锁。相反,如果无法在指定的超时内锁定表,则会失败。可以在SET statement_timeout接受的任何格式中指定超时。(允许的格式取决于您转储的服务器版本,但是所有版本都接受整数毫秒数。)

31)–load-via-partition-root
当转储表分区的数据时,复制或插入语句的目标是包含它的分区层次结构的根,而不是分区本身。这将导致在加载数据时为每一行重新确定适当的分区。这在重新加载服务器上的数据时可能很有用,因为在服务器上的行并不总是与原来的服务器上的行属于相同的分区。例如,如果分区列是text类型的,并且两个系统对用于对分区列进行排序的排序规则有不同的定义,那么可能会出现这种情况。

在从使用此选项生成的存档进行恢复时,最好不要使用并行性,因为pg_restore不知道给定存档数据项将加载数据到哪个分区。这可能会导致由于并行作业之间的锁冲突而导致的效率低下,甚至可能会导致由于在加载所有相关数据之前设置了外键约束而导致的重新加载失败。

32) --no-security-labels
不转储安全标签。

33)–lock-wait-timeout=timeout
不在转储开始时永远等待获取共享表锁。相反,如果无法在指定的超时内锁定表,则会失败。可以在SET statement_timeout接受的任何格式中指定超时。(允许的格式取决于您转储的服务器版本,但是所有版本都接受整数毫秒数。)

34)–no-comments
不转储注释。

35)–no-publications
Do not dump publications.

36)–no-subscriptions
Do not dump subscriptions.

37)–no-sync
默认情况下,pg_dump将等待所有文件安全写入磁盘。此选项将导致pg_dump在不等待的情况下返回,这将更快,但这意味着后续操作系统崩溃可能导致转储损坏。通常,此选项对测试有用,但不应在从生产安装转储数据时使用。

38)–no-synchronized-snapshots
该选项允许在9.2之前的服务器上运行pg_dump -j,有关详细信息,请参阅-j参数的文档。

39)–no-tablespaces
不输出命令来选择表空间。使用此选项,在恢复期间,所有对象都将在默认的表空间中创建。

此选项仅对纯文本格式有意义。对于存档格式,可以在调用pg_restore时指定该选项。

40)–no-unlogged-table-data
不转储未登录表的内容。此选项对是否转储表定义(模式)没有影响;它只禁止转储表数据。从备用服务器转储时,未登录表中的数据总是被排除。

41)–on-conflict-do-nothing
Add ON CONFLICT DO NOTHING to INSERT commands. This option is not valid unless --inserts, --column-inserts or --rows-per-insert is also specified.

42)–quote-all-identifiers
强制引用所有标识符。当从不同于pg_dump主版本的服务器转储数据库时,或者当输出要加载到不同主版本的服务器时,建议使用此选项。默认情况下,pg_dump只引用在其主版本中为保留字的标识符。在处理其他版本的服务器时,这有时会导致兼容性问题,因为这些服务器可能有稍微不同的保留字集。使用——quote-all标识符可以防止此类问题,但代价是读取转储脚本会比较困难。

43)–rows-per-insert=nrows
将数据转储为插入命令(而不是复制)。控制每个插入命令的最大行数。指定的值必须是一个大于零的数字。在重新加载期间发生的任何错误都只会导致有问题的插入中的部分行丢失,而不是整个表内容。

44)–section=sectionname
只转储指定的部分。部分名称可以是数据前、数据或后数据。可以多次指定此选项以选择多个节。默认是转储所有部分。

数据部分包含实际的表数据、大对象内容和序列值。后数据项包括索引、触发器、规则和约束(验证检查约束除外)的定义。预数据项包括所有其他数据定义项。

45)–serializable-deferrable
对转储使用可序列化的事务,以确保使用的快照与以后的数据库状态一致;但是,通过等待事务流中的一个不可能出现异常的点来做到这一点,这样就不会有转储失败或导致其他事务使用serialization_failure回滚的风险。

此选项对于仅用于灾难恢复的转储是不利的。当原始数据库继续更新时,用于加载数据库副本以进行报告或其他只读负载共享的转储可能很有用。没有它,转储可能反映与最终提交的事务的任何串行执行不一致的状态。例如,如果使用批处理技术,批处理可能在转储中显示为关闭,而不会显示批处理中的所有项。

如果在启动pg_dump时没有活动的读写事务,则此选项不会产生任何影响。如果读写事务处于活动状态,则转储的开始可能会延迟一段不确定的时间。一旦运行,有或没有开关的性能是相同的。

46)–snapshot=snapshotname
在对数据库进行转储时,使用指定的同步快照。

当需要将转储与逻辑复制槽(参见第48章)或与并发会话同步时,此选项非常有用。

在并行转储的情况下,将使用此选项定义的快照名称,而不是获取新的快照。

47)–strict-names
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.

48)–use-set-session-authorization
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.

二、pg_restore工具参数解析

pg_restore—从pg_dump创建的归档文件中还原PostgreSQL数据库。

语法:

pg_restore [connection-option...] [option...] [filename]

1.pg_restore 连接参数
(数与pg_dump基本相同)
1)-h host 或 --host=host
指定数据库服务运行的主机IP或主机名称。

2)-p port 或 --port=port
执行数据库的监听端口号,默认5432。

3)-U username 或 --username=username
指定要链接的数据库用户名。

4)-w 或 --no-password
从不提示密码。远程导出加此参数会导致命令错误,此选项一般用在数据库服务本地服务器导出时不指定密码。

5)-W 或 --password
强制 pg_dump 在连接一个数据库时提示密码。此参数选项可以不指定,因为如果服务器要求密码验证,pg_dump会自动提示密码输入,不指定时会浪费一个连接试图找出服务器是否需要面,指定时可避免额外的链接尝试。

6)–role=rolename
该选项会导致 pg_dump 在连接数据库时发送一个 SELECT ROLE rolename 命令。相当于切换到了指定的角色上,当已验证的用户缺少 pg_dump 运行需要的权限时,可以使用该选项指定的有相应权限的角色上。

不同的是pg_restore工具连接指定的数据库使用一下参数:

7)-d dbname 或 --dbname=dbname

2.pg_restore指定参数

1)filename
指定需要恢复的归档文件的位置(对于directory-format存档就是一个目录),如果没有指定,使用标准输出。

2)-a 或 --data-only
只恢复数据,而不是模式(数据定义)。如果存档中存在表数据、大型对象和序列值,则会恢复这些值。

此选项类似于 --section=data,但由于历史原因与指定 --section=data不同。

3)-c 或 --clean
在导入数据表前对数据库中相同表名的表清除然后将dump文件中的表导入进去,如果导入的数据库中没有dump文件中的表会有错误提示要清除的表不存在,不过这些错误提示是没有关系的(除非使用 --if-exists,否则如果目标数据库中没有对象,则可能会生成一些无害的错误消息。)

4)-C 或 --create
在还原之前创建数据库。如果还指定了 --clean,那么在连接到目标数据库之前,删除并重新创建它。

使用 --create, pg_restore还可以恢复数据库的注释(如果有的话),以及特定于此数据库的任何配置变量设置,即任何ALTER DATABASE……SET……ALTER ROLE… IN DATABASE … SET … 数据库的命令。还将恢复数据库本身的访问特权,除非指定了
–no-acl。

5)-d dbname 或 --dbname=dbname
连接到数据库dbname并直接还原到数据库。
Connect to database dbname and restore directly into the database.

6)-e 或 --exit-on-error
如果在向数据库发送SQL命令时遇到错误,则退出。默认值是继续,并在恢复结束时显示错误计数。

7)-f filename 或 --file=filename
为生成的脚本指定输出文件,或者为与-l一起使用的清单指定输出文件。使用-用于标准输出。

8)-F format 或 --format=format
指定档案的格式。没有必要指定格式,因为pg_restore将自动确定格式。如有指明,可以是下列其中一项:

a)c (custom)
归档文件采用pg_dump的自定义格式。
b)d (directory)
存档是一个目录存档。
c)t (tar)
该归档文件是一个tar归档文件。

9)-I index 或 --index=index
仅恢复已命名索引的定义。可以使用多个-I开关指定多个索引。

10)-j number-of-jobs 或 --jobs=number-of-jobs
使用多个并发作业运行pg_restore中最耗时的部分—加载数据、创建索引或创建约束的部分。此选项可以极大地缩短将大型数据库还原到运行在多处理器机器上的服务器的时间。

根据操作系统的不同,每个作业都是一个进程或一个线程,并使用到服务器的独立连接。

此选项的最佳值取决于服务器、客户机和网络的硬件设置。因素包括CPU内核的数量和磁盘设置。我们可以从服务器上的CPU内核数量开始,但是在许多情况下,大于这个数量的值也会导致更快的恢复时间。当然,过高的值将导致性能下降,因为抖动。

此选项仅支持自定义和目录存档格式。输入必须是常规文件或目录(而不是管道)。在发出脚本而不是直接连接到数据库服务器时,将忽略此选项。此外,多个作业不能与选项(单事务)一起使用。

11)-l 或 --list
列出档案的目录。该操作的输出可以用作-L选项的输入。注意,如果-n或-t之类的过滤开关与-l一起使用,它们将限制所列出的项。

12)-L list-file 或 --use-list=list-file
仅还原列表文件中列出的存档元素,并按它们在文件中出现的顺序还原它们。注意,如果-n或-t之类的过滤开关与-L一起使用,它们将进一步限制恢复的项。

list-file通常是通过编辑前一个-l操作的输出来创建的。可以移动或删除行,也可以通过在行开头放置分号(;)来注释掉行。请看下面的例子。

13)-n schema 或 --schema=schema
Restore only objects that are in the named schema. Multiple schemas may be specified with multiple -n switches. This can be combined with the -t option to restore just a specific table.

14)-N schema 或 --exclude-schema=schema
Do not restore objects that are in the named schema. Multiple schemas to be excluded may be specified with multiple -N switches.

When both -n and -N are given for the same schema name, the -N switch wins and the schema is excluded.

15)-O 或 --no-owner
Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O, any user name can be used for the initial connection, and this user will own all the created objects.

-P function-name(argtype [, …])
–function=function-name(argtype [, …])
Restore the named function only. Be careful to spell the function name and arguments exactly as they appear in the dump file’s table of contents. Multiple functions may be specified with multiple -P switches.

-R
–no-reconnect
This option is obsolete but still accepted for backwards compatibility.

-s
–schema-only
Restore only the schema (data definitions), not data, to the extent that schema entries are present in the archive.

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 “schema” in a different meaning.)

-S username
–superuser=username
Specify the superuser user name to use when disabling triggers. This is relevant only if --disable-triggers is used.

-t table
–table=table
Restore definition and/or data of only the named table. For this purpose, “table” includes views, materialized views, sequences, and foreign tables. Multiple tables can be selected by writing multiple -t switches. This option can be combined with the -n option to specify table(s) in a particular schema.

Note
When -t is specified, pg_restore makes no attempt to restore any other database objects that the selected table(s) might depend upon. Therefore, there is no guarantee that a specific-table restore into a clean database will succeed.

Note
This flag does not behave identically to the -t flag of pg_dump. There is not currently any provision for wild-card matching in pg_restore, nor can you include a schema name within its -t. And, while pg_dump’s -t flag will also dump subsidiary objects (such as indexes) of the selected table(s), pg_restore’s -t flag does not include such subsidiary objects.

Note
In versions prior to PostgreSQL 9.6, this flag matched only tables, not any other type of relation.

-T trigger
–trigger=trigger
Restore named trigger only. Multiple triggers may be specified with multiple -T switches.

-v
–verbose
Specifies verbose mode.

-V
–version
Print the pg_restore version and exit.

-x
–no-privileges
–no-acl
Prevent restoration of access privileges (grant/revoke commands).

-1
–single-transaction
Execute the restore as a single transaction (that is, wrap the emitted commands in BEGIN/COMMIT). This ensures that either all the commands complete successfully, or no changes are applied. This option implies --exit-on-error.

–disable-triggers
This option is relevant only when performing a data-only restore. It instructs pg_restore to execute 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, run pg_restore as a PostgreSQL superuser.

–enable-row-security
This option is relevant only when restoring the contents of a table which has row security. By default, pg_restore will set row_security to off, to ensure that all data is restored in to the table. If the user does not have sufficient privileges to bypass row security, then an error is thrown. This parameter instructs pg_restore to set row_security to on instead, allowing the user to attempt to restore the contents of the table with row security enabled. This might still fail if the user does not have the right to insert the rows from the dump into the table.

Note that this option currently also requires the dump be in INSERT format, as COPY FROM does not support row security.

–if-exists
Use conditional commands (i.e. add an IF EXISTS clause) to drop database objects. This option is not valid unless --clean is also specified.

–no-comments
Do not output commands to restore comments, even if the archive contains them.

–no-data-for-failed-tables
By default, table data is restored even if the creation command for the table failed (e.g., because it already exists). With this option, data for such a table is skipped. This behavior is useful if the target database already contains the desired table contents. For example, auxiliary tables for PostgreSQL extensions such as PostGIS might already be loaded in the target database; specifying this option prevents duplicate or obsolete data from being loaded into them.

This option is effective only when restoring directly into a database, not when producing SQL script output.

–no-publications
Do not output commands to restore publications, even if the archive contains them.

–no-security-labels
Do not output commands to restore security labels, even if the archive contains them.

–no-subscriptions
Do not output commands to restore subscriptions, even if the archive contains them.

–no-tablespaces
Do not output commands to select tablespaces. With this option, all objects will be created in whichever tablespace is the default during restore.

–section=sectionname
Only restore the named section. The section name can be pre-data, data, or post-data. This option can be specified more than once to select multiple sections. The default is to restore all sections.

The data section contains actual table data as well as large-object definitions. Post-data items consist of definitions of indexes, triggers, rules and constraints other than validated check constraints. Pre-data items consist of all other data definition items.

–strict-names
Require that each schema (-n/–schema) and table (-t/–table) qualifier match at least one schema/table in the backup file.

–use-set-session-authorization
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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Major_ZYH

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值