I'm not an expert. Yesterday I found out that SRID in PostGIS is property of the column - an actual constraint that is even stored in pg_constraints
table and then retrieved through geometry_columns
view. Previously I thought that SRID is set and stored per geometry record.
So given that, I now have several questions:
- If it's an actual constraint why it's not enforced - e.g. why is that I can still write into the column a geometry with any SRID?
- Why methods like
ST_SRID
orST_SETSRID
accept geometry as an argument rather than column name? - Also currently to fetch the geometries from DB we use local hardcoded map of SRIDs by region, can't we use SRIDs from
geometry_columns
instead? - What's the point of storing a SRID per column like that if it's not even used for anything anywhere?
ALTER COLUMN
); the system will enforce all inherent constraints of that data type onINSERT
orUPDATE
, including their typemods. Assuming your column is registered in the system relations: if it is of typeGEOMETRY
, it will accept all equal types, not considering their typemods; but if your column is of typeGEOMETRY(4326)
, the system will enforce the CRS typemod. The typemods are property of the type, and a column is defined by these types.