簡體   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