UpdateGeometrySRID
What is UpdateGeometrySRID?
UpdateGeometrySRID changes the SRID of a PostGIS geometry column — both the column's type modifier and each row's geometry. The function does not reproject coordinates.
1UpdateGeometrySRID(catalog_name varchar, schema_name varchar, table_name varchar, column_name varchar, new_srid_in integer) → text
2UpdateGeometrySRID(schema_name varchar, table_name varchar, column_name varchar, new_srid_in integer) → text
3UpdateGeometrySRID(table_name varchar, column_name varchar, new_srid_in integer) → textIt is intended for correcting SRID metadata, not for changing the actual CRS of the data — use ST_Transform for that.
When would you use UpdateGeometrySRID?
Use UpdateGeometrySRID after a data load where the shipped coordinates are known to be in one CRS but the column was created with a different SRID (or 0). One call updates the column's typmod and every row in place.
It is also useful in large migrations where manually running UPDATE ... SET geom = ST_SetSRID(geom, ...) would require a table rewrite; UpdateGeometrySRID handles the whole operation atomically.
FAQs
Does UpdateGeometrySRID reproject coordinates?
No. It only rewrites the SRID metadata on the column and rows. Use ST_Transform to change coordinates.
Why not just run ALTER TABLE ALTER COLUMN TYPE?
ALTER TABLE changes the typmod but not the SRID embedded in each row's binary header. UpdateGeometrySRID handles both in one call.
Can I undo it?
Yes — call UpdateGeometrySRID again with the original SRID.
Does it lock the table?
Yes. It runs an UPDATE on every row, so plan for the write lock on large tables and consider a maintenance window.