Skip to content

Commit

Permalink
sprint geometery and spatial index creation (#157)
Browse files Browse the repository at this point in the history
* Constants sprint creation

* Update sprint-geometery-and-spatial-index-creation.md

* fixed typo

* Delete data-management/sprint-geometery-and-spatial-index-creation directory

* upload geometry and spatial index creation sprint
  • Loading branch information
denisemyrick authored May 23, 2024
1 parent 75a4da9 commit 35bda39
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Oracle LiveLabs gives you access to Oracle's products to run a wide variety of labs and workshops; allowing you to experience our best technology, live!">
<title>Oracle LiveLabs</title>

<script src="https://oracle-livelabs.github.io/common/redwood-hol/js/jquery-1.11.0.min.js"></script>
<script src="https://oracle-livelabs.github.io/common/redwood-hol/js/jquery-ui-1.10.4.custom.js"></script>
<script src="https://oracle-livelabs.github.io/common/redwood-hol/js/main.min.js"></script>

<link rel="stylesheet" href="https://oracle-livelabs.github.io/common/redwood-hol/css/style.min.css" />
<link rel="shortcut icon" href="https://oracle-livelabs.github.io/common/redwood-hol/img/favicon.ico" />
</head>

<body>
<header class="hol-Header" role="banner">
<div class="hol-Header-wrap">
<div class="hol-Header-logo"><span>Oracle LiveLabs</span></div>
<a href="https://developer.oracle.com/livelabs" target="_blank" id="livelabs" title="Oracle LiveLabs"></a>
<div class="hol-Header-actions">
<button id="openNav" class="hol-Header-button hol-Header-button--menu rightNav" aria-label="Open Menu"
title="Open Menu">
<span class="hol-Header-toggleIcon"></span>
</button>
</div>
</div>
</header>

<div id="container">
<div id="leftNav">
<div id="toc"></div>
</div>
<div id="contentBox">
<main class="hol-Content" id="module-content"></main>
</div>
</div>

<footer class="hol-Footer">
<a class="hol-Footer-topLink" href="#top">Return to Top</a>
<div id="footer-banner"><div class="footer-row">
<div class="footer-content"><ul class="footer-links">
<li><a href="https://docs.oracle.com/pls/topic/lookup?ctx=en/legal&id=cpyr" target="_blank" aria-label="Open a new window to Oracle legal notices" data-lbl="copyright">© Oracle</a></li>
<li><a href="https://www.oracle.com/corporate/index.html" target="_blank" aria-label="Open a new window to learn more about oracle" data-lbl="about-oracle">About Oracle</a></li>
<li><a href="https://www.oracle.com/corporate/contact/" target="_blank" aria-label="Open a new window to contact oracle" data-lbl="contact-us">Contact Us</a></li>
<li class="footer-links-break"></li>
<li><a href="https://docs.oracle.com/en/browseall.html" target="_blank" aria-label="Open a new window to products a-z" data-lbl="products-a-z">Products A-Z</a></li>
<li><a href="https://www.oracle.com/legal/privacy/" target="_blank" aria-label="Open a new window to read more about Oracle terms of use and privacy" data-lbl="terms-of-use-and-privacy">Terms of Use & Privacy</a></li>
<li><a href="https://www.oracle.com/legal/privacy/privacy-policy.html#11" target="_blank" aria-label="Open a new window to read more about managing Oracle cookie preferences" data-lbl="cookie-preferences">Cookie Preferences</a></li>
<li><a href="https://www.oracle.com/legal/privacy/marketing-cloud-data-cloud-privacy-policy.html#adchoices" target="_blank" aria-label="Open a new window to ad choices" data-lbl="ad-choices">Ad Choices</a></li>
<li class="footer-links-break"></li><li class="last"><a href="https://docs.oracle.com/pls/topic/lookup?ctx=en/legal&id=cpyr" target="_blank" aria-label="Open a new window to Oracle legal notices" data-lbl="copyright">© Oracle</a></li>
</ul>
</div>
</div>
</div>
</footer>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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
<copy>CREATE TABLE spatial_test (geometry SDO_GEOMETRY );</copy>
```

2. Insert a point geometry into our new table. Note the constructor only requires a longitude, latitude coordinate.

```sql
<copy>INSERT INTO spatial_test VALUES (
sdo_geometry(- 106.1234, 26.1234) -- only coordinates required
);</copy>
```

3. Insert a polygon geometry into our new table. Note the use of the new constant constants.

```sql
<copy>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)) );</copy>
```

4. Create a spatial index. Note that the required spatial metadata is now automatically generated.

```sql
<copy>CREATE INDEX spatial_test_sidx
ON spatial_test (geometry)
INDEXTYPE IS mdsys.spatial_index_v2; -- metadata autogenerated</copy>
```

5. Optionally drop the table.

```sql
<copy>DROP TABLE spatial_test;</copy>
```

## 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

0 comments on commit 35bda39

Please sign in to comment.