filmov
tv
MySQL 8 - Create a Spatial Table With a SQL Script

Показать описание
Hello to everyone,
There are two ways how to create a SPATIAL TABLE, in the version 8.x, of MySQL. One it’s by using the “create a new table in the schema” interface, from the Workbench, and the other way, it’s by creating a SQL script. The first way it’s more friendly, and I teach how to do it in another video. The second way it’s more for experts, and it’s what I am going to explain in this video.
Just to remind, the SPATIAL TABLES are based on the shapefiles' characteristics, where each shapefile only allows the storage of one of the three types of geometries: polygons, lines, or points.
Because the procedures are similar, and the difference are only in the moment when I choose the geometry type of the table, in this video I will only demonstrate how to create a SPATIAL TABLE to store POLYGONS.
Let's see, step by step, how to accomplish the task.
SQL scripts used in this video:
----------------
CREATE TABLE demo_spatial (ogr_fid INT PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, municipality VARCHAR(40), shape POLYGON NOT NULL SRID 3857, SPATIAL INDEX(shape));
----------------
INSERT INTO geometry_columns VALUES (NULL, NULL, ‘demo_spatial’, 'shape', '2', '3857', 'POLYGON');
----------------
Software used to build this video:
There are two ways how to create a SPATIAL TABLE, in the version 8.x, of MySQL. One it’s by using the “create a new table in the schema” interface, from the Workbench, and the other way, it’s by creating a SQL script. The first way it’s more friendly, and I teach how to do it in another video. The second way it’s more for experts, and it’s what I am going to explain in this video.
Just to remind, the SPATIAL TABLES are based on the shapefiles' characteristics, where each shapefile only allows the storage of one of the three types of geometries: polygons, lines, or points.
Because the procedures are similar, and the difference are only in the moment when I choose the geometry type of the table, in this video I will only demonstrate how to create a SPATIAL TABLE to store POLYGONS.
Let's see, step by step, how to accomplish the task.
SQL scripts used in this video:
----------------
CREATE TABLE demo_spatial (ogr_fid INT PRIMARY KEY NOT NULL UNIQUE AUTO_INCREMENT, municipality VARCHAR(40), shape POLYGON NOT NULL SRID 3857, SPATIAL INDEX(shape));
----------------
INSERT INTO geometry_columns VALUES (NULL, NULL, ‘demo_spatial’, 'shape', '2', '3857', 'POLYGON');
----------------
Software used to build this video: