【发布时间】:2021-07-10 01:38:04
【问题描述】:
我在 postgres 的数据库中有下表(table_example):
id geom class area_total
1255 65f56f6565... type_1 1244589
1256 65f56f6566... type_2 2542542
我需要创建一个新列,从多边形的几何形状中接收多边形质心的值。
基于此链接 (How to add geometry column using pgAdmin),我尝试按如下方式进行所需的操作:
-- The idea is to first create a column that is of type geometry
ALTER TABLE table_example
ADD COLUMN column_geom_centroid geometry(geom);
-- And then assign the centroid value to the column
UPDATE table_example
SET column_geom_centroid = ST_Centroid(geom)
但是,当我运行第一个命令 (ALTER...) 时,会出现以下错误:
ERROR: Invalid geometry type modifier: geom
LINE 2: ADD COLUMN column_geom_centroid geometry(geom);
^
SQL state: 22023
Character: 70
【问题讨论】:
标签: sql postgresql pgadmin