mysqPoint型別查詢和插入操作:insert和select

雲棲希望。發表於2018-01-06

首先,建立一個表名為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

本文轉自部落格園知識天地的部落格,原文連結:mysq Point型別 查詢和插入操作:insert和select 如需轉載請自行聯絡原博主。


相關文章