mysq Point类型 查询和插入操作:insert和select

时间:2024-01-06 10:44:02

首先,创建一个表名为geometry2的表,然后增加一个名为gemo的point类型的字段。

insert方法有4中,例如以下所看到的:
//================================================================//
INSERT INTO `geometry2`.`gemo` VALUES(GeomFromText('POINT(1 1)'));

//================================================================//
INSERT INTO `geometry2`.`gemo` VALUES(PointFromText('POINT(1 1)'));

//================================================================//
SET @g = 'POINT(1 1)';
INSERT INTO `geometry2`.`gemo` VALUES(GeomFromText(@g));

//================================================================//
SET @g = GeomFromText('POINT(1 1)');
INSERT INTO `geometry2`.`gemo` VALUES(@g);

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

假设仅仅是用select(*) from gemo,select出来的结果会是乱码···

要想看到非乱码数据,用以下这个方法
//================================================================//
SELECT AsText(pos) FROM `geometry2`.`gemo`;

可得例如以下格式的数据:

mysql空间类型:Point类型的insert和select - Mooner - 楚天空阔歌声长

另附mysql官方站点的手冊:

http://dev.mysql.com/doc/refman/5.1/zh/spatial-extensions-in-mysql.html