gpt4 book ai didi

postgresql - 尽管给出了 --no-tablespaces,但 pg_restore 因缺少表空间而失败

转载 作者:行者123 更新时间:2023-11-29 12:17:07 25 4
gpt4 key购买 nike

我正在尝试使用以下命令将数据库导入 postgres:

"C:\Program Files\PostgreSQL\9.5\bin\pg_restore.exe" --dbname=postgres --clean --create --format=d --jobs=16 --no-tablespaces --host=localhost --username=postgres "S:\Directory-Dump_Inn"

精美的手册说:

--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.

我认为这意味着我不必创建转储来源的表空间。由于导入失败

ERROR: tablespace "ts_inn" does not exist 

我想,这个假设是错误的。那么手册中的解释是什么意思呢?如果我事先创建表空间,导入工作正常。

编辑:导入服务器版本为 9.5.4,导出服务器版本为 9.6.3。导出命令可能也很重要:

"C:\Program Files\PostgreSQL\9.6\bin\pg_dump.exe" --host localhost --port 5432 --username "postgres" --no-password  --format directory --section pre-data --section data --section post-data --compress 0 --jobs 4 --verbose --file "F:\Postgres-Backup\Directory-Dump_Inn" "inn" 2>> %logfile%

是导出遗漏--no-tablespaces的罪魁祸首吗?如果是,并且如果我将 --no-tablespaces 添加为 pg_dump 的参数,那么我为什么要在导入期间使用 --no-tablespaces?显然转储文件中不会有任何 CREATE TABLESPACE xxx

最佳答案

一个很像你的问题在 this 中被修复了2016 年 9 月提交修复 bug #14315 ,因此请确保您拥有带有最新补丁的 PostgreSQL 9.5 或更高版本。

但即使有了这些补丁,您的示例也会失败,因为您没有将 --no-tablespaces 添加到 pg_dump 的调用中。

这有点令人惊讶,但是要在转储中抑制 CREATE DATABASETABLESPACE 子句,调用 pg_restore 是不够的 --no-表空间。必须使用该选项创建转储。

关于postgresql - 尽管给出了 --no-tablespaces,但 pg_restore 因缺少表空间而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47349934/

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