乘风原创程序

  • PostGIS图层的导入导出
  • 2020/7/7 10:25:41
  • 导出

    -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