PostGIS的pg_dump:架构为空

时间:2015-11-24 21:37:42

标签: postgresql postgis

我需要将PostGIS安装从数据库A移动到新数据库B.我在A上有PostGIS 2.1.7,在B上有2.1.8。两个数据库都是相同的 - PostgreSQL的版本是9.4.4。 / p>

在A上配置PostGIS扩展程序如下:

pg_dump -Fc -b A -p 5433 -U postgres > A.dmp

同样在B上(postgis 2.1.8除外)。

我用于导出的命令:

pg_restore -Fc -d B -p 5432 A.dmp

恢复:

pg_restore: [archiver (db)] could not execute query: ERROR:  type "postgis.geometry" does not exist
LINE 9:     location postgis.geometry(Point,4326),
                     ^

以下是日志的一部分:

COPY spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) FROM stdin;
.....postgis..........postgres.....false.....347.............................0.....17220.....roles.
...TABLE DATA................N...COPY roles (id, name, createdate, updatedate, description, value) FROM stdin;
.....security..........services...

现在让我们看一下A.dmp - spatial_ref_sys表是空的,只是一个COPY命令,没有数据:

COPY spatial_ref_sys (srid, auth_name, auth_srid, srtext, proj4text) FROM stdin;
\.

问题是 - 为什么pg_dump没有转储PostGIS架构的内容?

UPD1:

一般文本格式转储的内容:spatial_ref_sys的数据:

edrivep1=# select count(*) from postgis.spatial_ref_sys;
 count
-------
  3911
(1 row)

但我们可以在那里看到3911条记录:

-bash-4.1$ pg_restore -l edrivep1.dmp | grep spatial
4932; 0 79804 TABLE DATA postgis spatial_ref_sys postgres

SaleID (PK)
Quantity
Date
Time
TotalPrice
TransactionID (FK)

1 个答案:

答案 0 :(得分:1)

问题得到解决。第二个数据库B上的postgis架构有一个错误的search_path - 当我改变postgis'架构到公共,search_path设置为' edrive,public,postgis'在BOTH数据库上,一切都很顺利。