gpt4 book ai didi

postgresql - 使用 pg_restore 恢复表不包括主键或索引

转载 作者:行者123 更新时间:2023-12-03 00:02:19 27 4
gpt4 key购买 nike

所以我使用 pg_dump 备份了一个表:

pg_dump -U bob -F c -d commerce -t orders > orders.dump

该表有多个列出的索引,例如主键

但是,当我使用 pg_restore 将此表恢复到另一个系统上的开发数据库时:

pg_restore -U bob -d commerce -t orders > orders.dump

未列出主键或索引

我做错了什么?

最佳答案

您没有做错任何事,不幸的是,pg_restore -t 仅恢复表,而不恢复其他内容,无论您如何创建转储以及转储本身内部的内容。V12 PostgreSQL docs 中已经以某种方式澄清了这一点。 ,其中指出:

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.

确保恢复表将包含所有索引的唯一方法是按名称寻址它们,例如:

pg_restore -U bob -d commerce -t orders -I index1 -I index2 -I index3 > orders.dump

关于postgresql - 使用 pg_restore 恢复表不包括主键或索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48860257/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com