Spatial SQL -> MySQL. Create polygon geometries

Here we'll create Spatially Enabled table and insert into it some geometry values. The values will represent polygon objects (Buldings, Gardens, etc.). Geometry value is created from the list of LAT-LONG coordinates using PolygonFromText() function.

CREATE TABLE poi_milan_fp
( idno INTEGER,
  name CHARACTER(80),
  ptyp CHARACTER(50),
  area FLOAT,
  g GEOMETRY);

INSERT INTO poi_milan_fp (idno,name,ptyp,area,gn)
VALUES(5, 'Duomo', '02 - building',0,
PolygonFromText('POLYGON((
9.190586853 45.464518970,
9.190602686 45.463993916,
9.191572471 45.464001929,
9.191613325 45.463884676,
9.192136130 45.463880767,
9.192111509 45.464095594,
9.192427961 45.464117804,
9.192417811 45.464112862,
9.192509035 45.464225851,
9.192493139 45.464371079,
9.192448471 45.464439002,
9.192387444 45.464477861,
9.192051402 45.464483037,
9.192012814 45.464643592,
9.191640825 45.464647090,
9.191622331 45.464506215,
9.190586853 45.464518970))'
)
);

INSERT INTO poi_milan_fp (idno,name,ptyp,area,gn)
VALUES (11, 'Giardini pubblici', '02 - garden',0,
PolygonFromText('POLYGON((
9.197915773 45.476819539,
9.195513514 45.472823358,
9.196395088 45.471905458,
9.197969097 45.470451939,
9.200557298 45.470952889,
9.201648922 45.472091272,
9.202453092 45.471989421,
9.204439767 45.474246289,
9.198739377 45.476916834,
9.197915773 45.476819539))'
)
);




sqlexamples.info