Postgresql

如何在具有不同 postgis 安裝(postgis 模式位置)的數據庫中使用 pg_restore?

  • November 19, 2019

我有 database1,其中 postgis 安裝在公共模式中。而 postgis 所在的 database2 位於一個名為 postgis 的模式中。

當我轉儲 database1.schema1 時,schema1.table1 將其 geom 列引用為 public.geometry。

因此 pg_restore 拋出“schema public 不存在”錯誤,因為 schema1.table1 具有 public.geometry 列,並且該模式不存在,也沒有在該模式中安裝 postgis。

如何在沒有模式限定幾何列的情況下製作乾淨的 pg_dump?

database2 search_path 指向模式 postgis。我正在使用 PostgresSQL 10。

你不能這樣做。在兩個數據庫中以相同的模式安裝 PostGIS。這在新數據庫中應該不是問題。

另一種方法是手動編輯轉儲文件,這既繁瑣又容易出錯。

正如 Laurenz 所說,您必須將 PostGIS 安裝在兩個數據庫中的相同模式中。

之後,可以通過以下方式遷移 postgis 擴展:https ://www.postgis.net/2017/11/07/tip-move-postgis-schema/

如果需要,可以在中間數據庫中完成遷移。

引用自:https://dba.stackexchange.com/questions/253265