I've got a postgreSQL/postGIS table whose geom column holds Geometry type (MultiLineString). I want to include in the table also Points and MultiPoints, so I tried to change the geometry type with

alter table lineas
alter column geom type geometry(geometrycollection);

However, it returns

ERROR:  Geometry type (MultiLineString) does not match column type (GeometryCollection)
SQL state: 22023

Why is that? A GeometryCollection column shoud be able to admit all other types, shouldn't it? How can it be solved?

1 Answer 1


A GeometryCollection can aggregate any kind of geometries but it is still a specific type of geometry.

If you want a column that can contain any kind of geometry, use the base type Geometry.

4.3.2. The GEOMETRY_COLUMNS VIEW of https://postgis.net/docs/using_postgis_dbmanagement.html says

To restrict the spatial column to a single type, use one of: POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION or corresponding XYM versions POINTM, LINESTRINGM, POLYGONM, MULTIPOINTM, MULTILINESTRINGM, MULTIPOLYGONM, GEOMETRYCOLLECTIONM. For heterogeneous (mixed-type) collections, you can use "GEOMETRY" as the type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.