小编Vog*_*612的帖子

使用 psql 和 --disable-triggers 恢复纯文本 pg_dump

我不得不用一个简短的脚本执行一些测试来更新我的一个表中的一些“遗留”数据。

尽管我很谨慎,但使用未经测试的脚本,我决定在这样做之前备份相关表。最简单的方法是:

pg_dump -a --file table.sql -t table database
Run Code Online (Sandbox Code Playgroud)

现在我做了我必须做的,检查了结果,发现它们很不令人满意。我心想:有一张桌子的备份我是多么幸运。

当我备份表格时,我已经被警告过:

pg_dump: NOTICE: there are circular foreign-key constraints among these table(s):
pg_dump:   table
pg_dump: You might not be able to restore the dump without using --disable-triggers or temporarily dropping the constraints.
pg_dump: Consider using a full dump instead of a --data-only dump to avoid this problem.
Run Code Online (Sandbox Code Playgroud)

我没有多想,但现在我们遇到了问题。实际上,有问题的表附加了多个触发器,我无法恢复 pg_restore 命令的table.sqlwith 选项--disable-triggers

如果我尝试以下命令,我会收到一条错误消息:

pg_restore -a -d database -t table -h localhost --disable-triggers table.sql
Run Code Online (Sandbox Code Playgroud)

即:

pg_restore: [archiver] …
Run Code Online (Sandbox Code Playgroud)

postgresql psql

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

postgresql ×1

psql ×1