diff --git a/data-management/sprint-geometery-and-spatial-index-creation/index.html b/data-management/sprint-geometery-and-spatial-index-creation/index.html new file mode 100644 index 00000000..7dd5d30b --- /dev/null +++ b/data-management/sprint-geometery-and-spatial-index-creation/index.html @@ -0,0 +1,62 @@ + + + + + + + + + Oracle LiveLabs + + + + + + + + + + + + +
+
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/data-management/sprint-geometery-and-spatial-index-creation/manifest.json b/data-management/sprint-geometery-and-spatial-index-creation/manifest.json new file mode 100644 index 00000000..729e3275 --- /dev/null +++ b/data-management/sprint-geometery-and-spatial-index-creation/manifest.json @@ -0,0 +1,12 @@ +{ + "workshoptitle": "LiveLabs Sprints", + "help": "livelabs-help-sprints_us@oracle.com", + "tutorials": [ + { + "title": "Sprint - How do I use simplified geometry and spatial index creation in Oracle Database 23ai?", + "description": "", + "filename": "sprint-geometery-and-spatial-index-creation.md" + } + ], + "task_type": "Sections" + } \ No newline at end of file diff --git a/data-management/sprint-geometery-and-spatial-index-creation/sprint-geometery-and-spatial-index-creation.md b/data-management/sprint-geometery-and-spatial-index-creation/sprint-geometery-and-spatial-index-creation.md new file mode 100644 index 00000000..afa6fe3f --- /dev/null +++ b/data-management/sprint-geometery-and-spatial-index-creation/sprint-geometery-and-spatial-index-creation.md @@ -0,0 +1,61 @@ +# How do I use simplified geometry and spatial index creation in Oracle Database 23ai? + +Duration: 5 minutes + +## Use constants to simplify geometry and spatial index creation in Oracle Database 23ai + +* Creating geometries is simplified with constants listed in section 2.2.1.1 SDO\_GTYPE Constants and 2.2.2.1 SDO\_SRID Constants in the [Spatial Developer's Guide](https://docs.oracle.com/en/database/oracle/oracle-database/23/spatl/spatial-datatypes-metadata.html). +* Creating longitude/latitude point geometries is simplified by requiring only coordinates in the constructor. +* Creating spatial indexes is simplified by automatically creating required spatial metadata. + +1. Let's start by creating a table for our geometries. + + > NOTE: In this example we load a point and polygon into the same table. While this is technically allowed, best practice is to store point features such as geocoded address locations in a separate table from polygon features such as county polygons. + + ```sql + CREATE TABLE spatial_test (geometry SDO_GEOMETRY ); + ``` + +2. Insert a point geometry into our new table. Note the constructor only requires a longitude, latitude coordinate. + + ```sql + INSERT INTO spatial_test VALUES ( + sdo_geometry(- 106.1234, 26.1234) -- only coordinates required + ); + ``` + +3. Insert a polygon geometry into our new table. Note the use of the new constant constants. + + ```sql + INSERT INTO spatial_test VALUES ( + sdo_geometry( + SDO_POLYGON2D, -- new constant + SDO_LONLAT, -- new constant + NULL, + sdo_elem_info_array(1, 1003, 3), + sdo_ordinate_array(- 106.41769, 26.17113, - 93.74627, 36.39554)) ); + ``` + +4. Create a spatial index. Note that the required spatial metadata is now automatically generated. + + ```sql + CREATE INDEX spatial_test_sidx + ON spatial_test (geometry) + INDEXTYPE IS mdsys.spatial_index_v2; -- metadata autogenerated + ``` + +5. Optionally drop the table. + + ```sql + DROP TABLE spatial_test; + ``` + +## Learn More + +* [Spatial Data Types and Metadata](https://docs.oracle.com/en/database/oracle/oracle-database/23/spatl/spatial-datatypes-metadata.html.) + +## Acknowledgements + +* **Author** - Denise Myrick, Senior Product Manager, Oracle Spatial and Graph +* **Contributors** - David Lapp and Ramu Murakami Gutierrez, Oracle Spatial and Graph +* **Last Updated By/Date** - Denise Myrick, May 2024