Inserting null value into geometry column using PostGIS

UPDATE "table" SET the_geom = NULL

This will work unless you have a NOT NULL-constraint on the geom-column.


Common approach when creating spatial tables is ensure that certain constraints are accomplished. This common constraints can be checked in the documentation of populate_geometry_columns.

One of these constraints is add to the geometry field a NOT NULL check. If you really need a table that admits null geometries you can remove the constraint for that table:

ALTER TABLE my_table ALTER COLUMN my_column DROP NOT NULL;

But have null geometries is usually a bad idea, because some software can have problems handling it. Depending on your use case probably a better idea is have another table that keeps the removed points.

Tags:

Postgis