Postgresql postgres恢复报告伪主键问题

Postgresql postgres恢复报告伪主键问题,postgresql,Postgresql,我正在尝试使用以下命令还原Postgres数据库: pg_restore --verbose -h localhost -p 5436 -d my_database --format=c --clean --no-owner --no-privileges --no-tablespaces --jobs=1 Sunday2.backup 在还原过程中,我看到以下错误: pg_restore: [archiver (db)] Error from TOC entry 2540; 0 16531

我正在尝试使用以下命令还原Postgres数据库:

pg_restore --verbose -h localhost -p 5436 -d my_database --format=c --clean --no-owner --no-privileges --no-tablespaces --jobs=1 Sunday2.backup
在还原过程中,我看到以下错误:

pg_restore: [archiver (db)] Error from TOC entry 2540; 0 16531 TABLE DATA foo_searchresult uoj9bg6vn4cqm
pg_restore: [archiver (db)] COPY failed for table "foo_searchresult": ERROR:  duplicate key value violates unique constraint "foo_searchresult_pkey"
DETAIL:  Key (id)=(63) already exists.
CONTEXT:  COPY foo_searchresult, line 1
我返回源数据库并运行了以下操作:

select id, count(*)
from foo_searchresult
group by id
having count(*) > 1
什么都没有

现在,如果我只是尝试将该表恢复到一个全新的数据库中:

pg_restore --verbose -h localhost -p 5436 -d brand_new_database --format=c --clean --no-owner --no-privileges --no-tablespaces --jobs=1 -t foo_searchresult Sunday2.backup
它回来时是干净的

更新:我刚刚尝试将整个备份恢复到一个全新的数据库,它似乎已经通过了foo_searchresult,没有问题

(顺便说一句,源数据库是9.4,目标数据库是9.5,但我使用9.4或9.5发行版的pg_还原得到了相同的结果。)

更新:看来删除数据库,然后创建一个空数据库并重新加载(而不是使用--clean标志)解决了一大堆问题


不管怎么说,我的问题是“以前有没有人见过这个问题,或者知道如何解决它。”

你的问题是什么?
使用count(*)>1
可能会得到更多的结果