MySQL/POINT:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第73行: 第73行:


== 更新数据 ==
== 更新数据 ==
{{leftrightflex|<syntaxhighlight lang="mysql">
update `test-location` set location=st_GeomFromText('POINT(123 100)') where id =1;</syntaxhighlight>|{{consoleout|<pre>
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
</pre>}}}}

2022年8月9日 (二) 09:57的版本

测试数据

mysql 之后的版本,空间数据类型的操作函数在命名上统一在前面加上ST,如 GeomFromText 改为 ST_GeomFromText。

创建测试表和字段。

模板:Leftrightflex

模板:Leftrightflex

添加数据还可以使用其他语句。

SET @tempdata = 'POINT(100 100)';
INSERT INTO `test-location`(location, text) VALUES (
  ST_GeomFromText(@tempdata),
  '测试点3'
);
/** or **/
SET @tempdata = ST_GeomFromText('POINT(100 100)');
INSERT INTO `test-location`(location, text) VALUES (
  @tempdata,
  '测试点4'
);

函数

ST_GeomFromText

ST_PointFromText

查询数据

模板:Leftrightflex

ST_AsText 模板:Leftrightflex

更新数据

模板:Leftrightflex