mysql:插⼊GEOMETRY相关字段类型
(point,linestring等)web游戏代码
版权声明:本⽂为博主原创⽂章,未经博主允许不得转载。 blog.csdn/zzc_zcc/article/details/78836505
对于mysql字段类型,point,linestring等相关空间坐标字段,我们在insert时可能会出现:1416 - Cannot get geometry object from data you send to the GEOMETRY field 等相关错误。这可能是insert语句写的不对,下⾯演⽰⼀下相关操作及对应结果。
CREATE TABLE `test` (
`id` int(11) NULL DEFAULT NULL ,
linux常用命令pwd`lstr` linestring NULL DEFAULT NULL ,
mysql面试题csdn`pt` point NULL DEFAULT NULL
)
ENGINE=InnoDB
DEFAULT CHARACTER SET=utf8 COLLATE=utf8_croatian_ci
ROW_FORMAT=COMPACT
delete free;
typescript开发桌面程序字段‘lstr’ 是linestring类型,‘pt’是point类型。
直接贴出能正确插⼊的sql语句
对于linestring类型:
insert into test(id,lstr) values (1,POINTFROMTEXT('LINESTRING(10 15)')); ----成功
insert into test(id,lstr) values (1,GeomFromText('LINESTRING(1 -1)')); ----成功
insert into test(id,lstr) values (1,'LINESTRING(10 15)'); ----失败
1416 - Cannot get geometry object from data you send to the GEOMETRY field
insert into test(id,lstr) values (1,LINESTRING('11','12')); ----失败
1367 - Illegal non geometric ''11'' value found during parsing
对于point类型:
insert into test(id,pt) values (1,POINTFROMTEXT('POINT(10 15)')); ----成功
insert into test(id,pt) values (1,GeomFromText('POINT(1 -1)')); ----成功
insert into test(id,pt) values (1,'POINT(12 13)'); ----失败
1416 - Cannot get geometry object from data you send to the GEOMETRY field
chrome浏览器72及以上是什么意思insert into test(id,pt) values (1,POINT('10','15')); ----成功
这⾥提⼀下,对于阿⾥云的rds数据库,point类型或者linestring类型可以通⽤。即在point字段能存linestring类型数据,在linestring字段能存point类型数据。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论