繁体   English   中英

pg_restore错误:“关系不存在”并创建新数据库

[英]pg_restore ERROR: “Relation does not exist” and creating new database

我已经使用以下方法备份了要还原到新数据库中的特定表:

call pg_dump -Fc -h server -d database -U user -p password -v -f dump.sql -t public.table1 -t public.table2

而且我没有问题。

然后,我想通过使用pg_restore创建一个新数据库来还原转储:

call pg_restore --clean --create -d temp -h server -p password -U user dump.sql

这给我一个“数据库临时不存在”的错误。 据我所知,这应该已经创建了数据库并对其进行了还原。

我然后手动创建“临时”数据库并运行:

call pg_restore --clean --create -d temp -h server -p password -U user dump.sql

这会继续进行,但不会创建表,并且给我一个错误“ relation table1”和“ relation table2”不存在,并且只会为两个表创建相应的id_sequences。

我真正想要的是不必手动创建新数据库,并且可以使用以下命令通过pg_restore将备份中的所有表还原到全新的数据库中:

call pg_restore --clean --create -d temp -h server -p password -U user dump.sql

据我了解。

为了创建数据库temp ,首先需要将pg_restore连接到另一个数据库。

因此,使用-d temp不会-d temp 您必须指定一个现有数据库,通常是postgres

pg_restore将连接到该数据库,发出CREATE DATABASE temp ,连接到temp并继续还原数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM