I need to do a simple merge polygon in PostGIS. The attribute table from both input shapefiles needs to be preserved. This is easily done In QGIS by using the merge polygon tool. But I don’t know how to do this in PostGIS.
I want to merge poly1 and poly2 – see picture (done in QGIS).
I have tried with the code below, but this gives way to many rows (should be around 5000, but it gives more 1 millions rows:
CREATE TABLE land_merge as SELECT ST_Union(poly1.geom, poly2.geom) as geom FROM poly1, poly2;