mysql gis
中文:
http://dev.mysql.com/doc/refman/5.1/zh/spatial-extensions-in-mysql.html#gis-class-polyg
on
下文为收集资料整理后,并测试后结果
当前只有
MyISAM
引擎的数据表支持地理空间数据的存储
建表:
CREATE DATABASE geodatabase;
USE geodatabase;
CREATE TABLE test(
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(128) NOT NULL,
pnt POINT,
line LINESTRING,
pgn POLYGON
)ENGINE=MyISAM;
添加空间列,
在
geom
表里添加可以存储
point
类型数据
ALTER TABLE geom ADD pt POINT;
用以下
SQL
插入一条空间数据
INSERT INTO `test` VALUES(
null,
'a test string',
POINTFROMTEXT('POINT(15 20)'),
LINESTRINGFROMTEXT('LINESTRING(0 0, 10 10, 20 25, 50 60)'),
POLYGONFROMTEXT('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')
);