Skip to content

Commit 008c87a

Browse files
authored
Create point-data-type.sql
1 parent 7e8a096 commit 008c87a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Create example table
2+
CREATE TABLE locations (
3+
id INT AUTO_INCREMENT PRIMARY KEY,
4+
name VARCHAR(255),
5+
coordinates POINT NOT NULL SRID 4326,
6+
SPATIAL INDEX(coordinates)
7+
);
8+
-- Add example data
9+
INSERT INTO locations (name, coordinates)
10+
VALUES ('Eiffel Tower', ST_PointFromText('POINT(2.2945 48.8584)', 4326));
11+
-- Query example data
12+
SELECT name,
13+
ST_Distance_Sphere(coordinates,
14+
ST_PointFromText('POINT(49.2827 -123.1207)', 4326))
15+
AS distance_meters
16+
FROM locations;

0 commit comments

Comments
 (0)