我用pg_restore恢复了一个数据库。我发现数据已恢复,但它抛出了一些错误。这些错误的原因是什么?
这是用于还原的命令
pg_restore -U postgres -d newdb08aug19 -j5 remote
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 7616;
2606 36663585 FK CONSTRAINT card_history_cashcard_id_fk unify37
pg_restore: [archiver (db)] could not execute query: ERROR: relation "public.voucher" does not exist
Command was: ALTER TABLE ONLY finance.card_history
ADD CONSTRAINT card_history_cashcard_id_fk FOREIGN KEY (cashcard_id) REFERENCES pu...
pg_restore: [archiver (db)] Error from TOC entry 7614; 2606 36662489 FK CONSTRAINT card_history_coupon_id_fk unify37
pg_restore: [archiver (db)] could not execute query: ERROR: relation "public.cpn" does not exist
Command was: ALTER TABLE ONLY finance.card_history
ADD CONSTRAINT card_history_coupon_id_fk FOREIGN KEY (coupon_id) REFERENCES public...
pg_restore: [archiver (db)] Error from TOC entry 7615; 2606 36663406 FK CONSTRAINT card_history_domno_fk unify37
pg_restore: [archiver (db)] could not execute query: ERROR: relation "public.ssgdom" does not exist
Command was: ALTER TABLE ONLY finance.card_history
ADD CONSTRAINT card_history_domno_fk FOREIGN KEY (domno) REFERENCES public.ssgdom(...
造成这些错误的原因是什么?
您只转储了数据库的一部分(可能使用-n finance
之类的东西,它只会转储该架构中的对象(。
因此,引用未包含在转储中的表的外键约束将在还原转储时导致错误消息。
除约束之外的所有内容都将正确恢复。