PostGIS图层的导入导出

导出

-U 用户名
-t 数据库表
database 数据库
pg_dump -U user -t \"country\" -f /tmp/country.sql database

导入

psql -U user -d database -f /tmp/country.sql

问题记录

如果使用Navicat导出的数据可能出现错误

...
en selected to create in
ERROR:  relation "public.country_m_gid_seq" does not exist
...

在创建表之前添加下面语句,创建序列

CREATE SEQUENCE country_gid_seq;

添加结果为:

...
-- ----------------------------
-- Table structure for Country
-- ----------------------------
DROP TABLE IF EXISTS "public"."Country";
CREATE SEQUENCE country_gid_seq;
CREATE TABLE "public"."Country" (
  "id" int4 NOT NULL DEFAULT nextval('"Country_id_seq"'::regclass),
  "the_geom" "public"."geometry",
  "sqkm" float8,
  "sqmi" float8,
  "color_map" varchar(1) COLLATE "pg_catalog"."default",
  "capital" varchar(50) COLLATE "pg_catalog"."default",
  "country" varchar(50) COLLATE "pg_catalog"."default",
  "pop_1994" float8,
  "continent" varchar(20) COLLATE "pg_catalog"."default"
)
;
...

本文地址:https://blog.csdn.net/this_is_id/article/details/107153240

THE END
喜欢就支持一下吧
点赞8分享