What is the usage of mysql geometry?

The Geometry type in MySQL is used to store spatial data such as points, lines, polygons, and other geographical spatial data. It can be used to represent maps, locations, spatial relationships, and more. Geometry type can store various spatial data and supports a variety of functions for querying, analyzing, and manipulating spatial data.

Common types of Geometry include Point, LineString, and Polygon. One can utilize spatial functions in MySQL to manipulate Geometry data, such as calculating the distance between two geometric objects, or determining if a point is inside a polygon.

You can use the following syntax in MySQL to create columns of Geometry type.

CREATE TABLE table_name (
    column_name GEOMETRY
);

You can then use the INSERT statement to insert data of Geometry type into the table.

INSERT INTO table_name (column_name) VALUES (ST_GeomFromText('POINT(1 1)'));

Geometry data can be manipulated and queried using spatial functions during retrieval.

SELECT * FROM table_name WHERE ST_Contains(column_name, ST_GeomFromText('POINT(1 1)'));
bannerAds