PostGIS – Set SRID for Mixed Geometry Type

geometrypostgissqlsrid

I have a geometry column with mixed geometries like polygon, multi polygon. I am trying to set SRID for it using below query but I get the below error. What type of geometry has to be given when we have multi polygon and polygon type in one column?

Query:-

ALTER TABLE geo_table
ALTER COLUMN geom TYPE geometry(POLYGON,4326) USING ST_TRANSFORM(ST_SetSRID(geometry,3857),4326)

Error:-

ERROR:  Geometry type (MultiPolygon) does not match column type (Polygon)

Best Answer

you can use the generic geometry type. Also make sure to spell the proper column name in the using

ALTER TABLE geo_table
  ALTER COLUMN geom TYPE geometry(geometry,4326) 
    USING ST_TRANSFORM(ST_SetSRID(geom ,3857),4326);
Related Question