小编Ian*_*n23的帖子

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

我已经备份了我想要恢复到新数据库中的特定表,使用:

call pg_dump -Fc -h server -d database -U user -p password -v -f dump.sql -t public.table1 -t public.table2
Run Code Online (Sandbox Code Playgroud)

我没有问题。

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

call pg_restore --clean --create -d temp -h server -p password -U user dump.sql
Run Code Online (Sandbox Code Playgroud)

这给了我一个“数据库临时不存在”的错误。据我所知,这应该已经创建了数据库并恢复了它。

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

call pg_restore --clean --create -d temp -h server -p password -U user dump.sql
Run Code Online (Sandbox Code Playgroud)

这将贯穿始终,但不会创建表并给我一个错误“ relation table1”和“ relation table2”不存在,并且只为两个表创建相应的 id_sewuences。

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

call pg_restore --clean --create -d temp -h server -p password -U user dump.sql
Run Code Online (Sandbox Code Playgroud)

据我了解。

请帮助,非常令人沮丧

postgresql psql pg-dump exists pg-restore

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

标签 统计

exists ×1

pg-dump ×1

pg-restore ×1

postgresql ×1

psql ×1