PostgreSQL/PostGIS:shp2pgsql INSERT 而不是创建新表

Mar*_* A. 3 postgresql postgis shapefile pgadmin

您好,我对 PostgreSQL/PostGIS 非常陌生,刚刚按照本教程学习了如何将 Shapefiles 转换为 SQL 文件并使用 shp2pgsql 将其导入到 PostGIS 。我注意到,每当我转换 Shapefile 时,它​​都会生成一个包含 CREATE TABLE 语句的 SQL 文件。现在我的问题是,有没有办法或者甚至可以将新的形状文件(带有新的图层组)插入到现有的表中,而不是创建一个新的表?

我希望我解释得很好。谢谢。

Bar*_*KIN 7

您可以在命令行中使用附加选项。像这样:

.\shp2pgsql.exe -c -I -g "geom" fistShpFile.shp
.\shp2pgsql.exe -a  -g "geom"   nextShpFile.shp
.\shp2pgsql.exe -a  -g "geom"   nextShpFile.shp
...
Run Code Online (Sandbox Code Playgroud)
(-d|a|c|p) These are mutually exclusive options:

-d Drops the table, then recreates it and populates it with current shape file data.
-a Appends shape file into current table, must be exactly the same table schema.
-c Creates a new table and populates it, default if you do not specify any options. 
-p Prepare mode, only creates the table.
Run Code Online (Sandbox Code Playgroud)

http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg

或者用于shp2pgsql -?其他选项。