从 workbench 插入一个点到 MySQL 8.0

Inserting a point into MySQL 8.0 from workbench

我有一个名为 'coordinates' 的列,类型为 'point'。

这个查询:

update `my-db`.`community` 
set `coordinates`= POINT( 31.9931217, 35.2823115 ) 
where 'id' = 1;

Returns 出现以下错误:

cannot get geometry object from data you send to the GEOMETRY field

此处的正确格式是什么?

开头:'id' 不是有效的列名(这是一个字符串乱码)。作为一般提示,您应该避免引用列名,除非确实有必要(即当名称包含特殊字符或以数字开头,或与保留字冲突时)。

除此之外,您的语法应该有效,如 described in the documentation and tested in this DB Fiddle

作为替代,您也可以try and use ST_GeomFromText(),如下:

update `my-db`.`community` 
SET `coordinates`= ST_GeomFromText('POINT(31.9931217 35.2823115)')
where `id` = 1;

看起来正确的语法是

UPDATE my-db.community SET coordinates=GeomFromText('POINT(31.9931217 35.2823115)') WHERE 'id' = 1;

试试看