Description\n-----------\n\nOn MyISAM, Aria and InnoDB tables, MariaDB can create spatial indexes (an R-tree index) using syntax similar to that for creating regular indexes, but extended with the SPATIAL keyword. Columns in spatial indexes must be declared NOT NULL.\n\nSpatial indexes can be created when the table is created, or added after the fact:\n\n``sql\nCREATE TABLE geom (g GEOMETRY NOT NULL, SPATIAL INDEX(g));\n`\n\n`sql\nALTER TABLE geom ADD SPATIAL INDEX(g);\n`\n\n`sql\nCREATE SPATIAL INDEX sp_index ON geom (g);\n`\n\nSPATIAL INDEX creates an R-tree index. For storage engines that support non-spatial indexing of spatial columns, the engine creates a B-tree index. A B-tree index on spatial values is useful for\\\nexact-value lookups, but not for range scans.\n\nFor more information on indexing spatial columns, see CREATE INDEX.\n\nTo drop spatial indexes, use ALTER TABLE or DROP INDEX:\n\n`sql\nALTER TABLE geom DROP INDEX g;\n`\n\n`sql\nDROP INDEX sp_index ON geom;\n`\n\nData-at-Rest Encryption\n\nIf innodb_checksum_algorithm is set to full_crc32 or strict_full_crc32`, and if the table does not use ROW_FORMAT=COMPRESSED, InnoDB spatial indexes are encrypted if the table is encrypted.\n\nSee MDEV-12026 for more information.\n\nURL: https://mariadb.com/docs/server/reference/sql-structure/geometry/spatial-index