Oracle LiveLabs实验:Introduction to Oracle Spatial

Posted dingdingfish

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle LiveLabs实验:Introduction to Oracle Spatial相关的知识,希望对你有一定的参考价值。

本实验介绍了适用于 Oracle Spatial功能。

此实验申请地址在这里,时间为60分钟。

此实验的帮助见这里

Oracle Spatial以前是单独收费的数据库选件,目前已包含在数据库企业版中。

Introduction

关于 Oracle Spatial

Oracle 的使命是帮助人们以新的方式查看数据、发现洞察并释放无限可能。 空间分析是关于理解基于地理关系的复杂交互——根据人员、资产和资源的位置来回答问题。 空间洞察力使您能够提供更好的客户服务、优化员工队伍、定位零售和配送中心、评估销售和营销活动等。 借助 Oracle 的空间产品,开发人员、数据库专业人员和分析师可以使用一整套空间数据管理、分析和可视化工具,将空间分析和映射集成到企业级数据管理基础架构(Oracle 数据库和 Oracle Exadata)上的应用程序中。

如下图所示,Oracle 数据库的空间特性为基本和高级空间数据类型提供了可扩展的高性能存储、处理和分析。 还提供了一系列可部署的 Java EE 组件来支持常见的中间层服务。

更多信息,请访问 https://oracle.com/goto/spatial

研讨会概述

在本次研讨会中,您将创建和配置空间数据并执行一些基本的空间查询。 该方案涉及WAREHOUSES, BRANCHES,和 COASTAL_ZONE。 WAREHOUSES 和 BRANCHES 是点,COASTAL_ZONE 是多边形。 您将创建和配置这些空间表,然后执行空间查询以识别邻近和包含的项目。

先决条件

  • 本次研讨会需要访问 Oracle 数据库和 SQL 客户端(即 SQL Developer、SQL Developer Web、SQL*Plus),以创建示例数据。
  • 不需要以前使用过 Oracle Spatial 的经验。

致谢

本实验的作者为David Lapp, 数据库产品经理,以及Marion Smith。

实验 1:配置自治数据库

在OCI中创建,ATP或ADW都可以。很快,几分钟就好。

其实此实验有一个Oracle普通的数据库也是可以的

实验 2:连接到 ADB 并运行您的第一个查询

介绍

在本实验中,您将使用 SQL 工作表探索数据库实例随附的示例数据集。约5分钟。

本实验使用 SQL 工作表,它是 Oracle 自治数据库的数据库操作基于 Web 的界面的功能之一。

本实验将演示对 ADW 开箱即用提供的示例数据集的查询。 ADW 提供 Oracle 销售历史示例模式和星型模式基准 (SSB) 数据集。 这些数据集分别位于 SH 和 SSB 模式中。但实际上这两个模式都不会在实验中使用到。

您将对 SSB 数据集运行基本查询,该数据集是一个 1 TB 的数据集,其中包含一个包含大约 60 亿行的事实表和多个维度表。

目标

  • 了解如何使用 SQL Worksheet 连接到新的自治数据库
  • 了解 Star Schema Benchmark (SSB) 和 Sales History (SH) 样本数据集
  • 对 ADW 示例数据集运行查询

任务 1:连接 SQL Worksheet

其实SQL Worksheet既可以用本地版的SQL Developer,也可以用云端Database Action中的SQL Developer Web版(Database Action>Development>SQL)。使用后者,可以免除配置接口的工作。

任务 2:在 SQL Worksheet 中运行脚本

运行以下SQL

select /* low */ c_city,c_region,count(*)
from ssb.customer c_low
group by c_region, c_city
order by count(*);

UNITED KI1	EUROPE      	119082
UNITED ST4	AMERICA     	119245
MOZAMBIQU2	AFRICA      	119283
INDIA    2	ASIA        	119380
ETHIOPIA 5	AFRICA      	119393
...

如果可能,ADW 还会为您缓存查询结果。 如果您多次运行相同的查询,您会注意到缓存结果后的响应时间要短得多。

实验 3:创建示例空间数据

本实验将引导您完成在 Oracle 数据库中创建示例空间数据的步骤。约10分钟。

Oracle 数据库原生数据类型 SDO_GEOMETRY存储空间数据(点、线、多边形)。 Oracle 数据库还为高性能空间操作提供原生空间索引。 此空间索引依赖于为存储空间数据的每个表和几何列输入的空间元数据。 一旦空间数据被发布和索引,强大的 API 就可以用于执行空间分析、计算和处理。

SDO_GEOMETRY 类型具有以下格式:

SDO_GEOMETRY( 
 [geometry type],           --ID for point/line/polygon
 [coordinate system],       --ID of coordinate system
 [point coordinate],        --for points only
 [line/polygon info],       --for lines/polygons only
 [line/polygon coordinates] --for lines/polygons only
  )

最常见的几何类型是二维的:

ID类型
2001Point
2002Line
2003Polygon

最常见的坐标系是:

ID坐标系
4326Latitude/Longitude (经纬度)
3857World Mercator(世界墨卡托)

使用纬度/经度时,请注意纬度是 Y 坐标,经度是 X 坐标。 由于坐标被列为 X,Y 对,因此这些值实际上按经度、纬度的顺序排列。

以下是使用纬度/经度坐标的示例几何点形状:

SDO_GEOMETRY( 
 2001,               --2D point
 4326,               --latitude/longitude
 SDO_POINT_TYPE(     
    -100.123, 20.456 --coordinate
    ),         
 NULL,               --for lines/polygons only
 NULL                --for lines/polygons only
  )

以下是使用纬度/经度坐标的示例几何多边形:

SDO_GEOMETRY( 
 2003,                  --2D polygon
 4326,                  --latitude/longitude
 NULL,                  --for points only       
 SDO_ELEM_INFO_ARRAY(
      1, 1003, 1        --indicates simple exterior polygon
        ), 
 SDO_ORDINATE_ARRAY(   
    -98.789065,39.90973, -- coordinates
    -101.2522,39.639537,
    -99.84374,37.160316,
    -96.67987,35.460699,
    -94.21875,39.639537,
    -98.789025,39.90973
      )
    )
);

SDO_ELEM_INFO_ARRAY中的数值(1, 1003, 1)是固定搭配,表示一个多边形(外部多边形环)。

在本实验中,您将:

  • 创建带有几何列的表
  • 填充几何图形
  • 创建空间元数据和索引

任务 1:创建带坐标的表

我们首先创建带有纬度、经度坐标的表格。 这是创建空间数据的常见起始任务,例如来自 GPS 的坐标,或来自地理编码街道地址或 IP 地址的坐标。

运行以下脚本:

CREATE TABLE WAREHOUSES (WAREHOUSE_NAME VARCHAR2(30), LAT NUMBER, LON NUMBER);
CREATE TABLE BRANCHES (BRANCH_NAME VARCHAR2(30),ZIPCODE VARCHAR2(5), LAT NUMBER, LON NUMBER, BRANCH_TYPE VARCHAR2(30));
INSERT INTO WAREHOUSES VALUES ('Amarillo Warehouse',35.532226,-101.557617);
INSERT INTO WAREHOUSES VALUES ('Odessa Warehouse',31.334871,-102.062988);
INSERT INTO WAREHOUSES VALUES ('San Antonio Warehouse',29.496987,-98.833007);
INSERT INTO WAREHOUSES VALUES ('Dallas Warehouse',33.027087,-97.316894);
INSERT INTO WAREHOUSES VALUES ('Houston Warehouse',30.069093,-95.317382);
INSERT INTO WAREHOUSES VALUES ('Abelene Warehouse',32.583849,-99.667968);
INSERT INTO WAREHOUSES VALUES ('Waco Warehouse',31.27855,-97.097167);
INSERT INTO BRANCHES VALUES('Marshall Branch','75672',32.50555,-94.35579,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Austin Branch-2','78745',30.20538,-97.75902,'RETAIL');
INSERT INTO BRANCHES VALUES('Grand Prairie Branch','75050',32.76199,-96.99732,'RETAIL');
INSERT INTO BRANCHES VALUES('Pasadena Branch','77505',29.64587,-95.15763,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Sulphur Springs Branch','75482',33.12357,-95.5972,'RETAIL');
INSERT INTO BRANCHES VALUES('San Angelo Branch-1','76901',31.44721,-100.49426,'RETAIL');
INSERT INTO BRANCHES VALUES('Houston Branch-6','77025',29.67853,-95.43044,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Mount Pleasant Branch','75455',33.17527,-94.98048,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Palestine Branch','75802',31.77344,-95.63011,'RETAIL');
INSERT INTO BRANCHES VALUES('Amarillo Branch-3','79119',35.11141,-101.91082,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Weatherford Branch','76086',32.75696,-97.70715,'RETAIL');
INSERT INTO BRANCHES VALUES('Port Lavaca Branch','77979',28.66005,-96.422,'RETAIL');
INSERT INTO BRANCHES VALUES('Tomball Branch','77375',30.015,-95.5912,'RETAIL');
INSERT INTO BRANCHES VALUES('Hebbronville Branch','78361',27.30652,-98.67612,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Beaumont Branch-1','77706',30.11087,-94.13984,'RETAIL');
INSERT INTO BRANCHES VALUES('Mabank Branch','75147',32.36565,-96.10197,'RETAIL');
INSERT INTO BRANCHES VALUES('Quitman Branch','75783',32.79578,-95.44701,'RETAIL');
INSERT INTO BRANCHES VALUES('Kerrvile Branch','78028',30.04845,-99.13948,'RETAIL');
INSERT INTO BRANCHES VALUES('Goldthwaite Branch','76844',31.44557,-98.5275,'RETAIL');
INSERT INTO BRANCHES VALUES('Katy Branch','77450',29.7848,-95.7326,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Bowie Branch-1','76230',33.53709,-97.87829,'RETAIL');
INSERT INTO BRANCHES VALUES('Weslaco Branch','78596',26.17235,-97.98209,'RETAIL');
INSERT INTO BRANCHES VALUES('Eagle Pass Branch','78852',28.6865,-100.47394,'RETAIL');
INSERT INTO BRANCHES VALUES('Tyler Branch','75711',32.32208,-95.30069,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Uvalde Branch','78801',29.23102,-99.75492,'RETAIL');
INSERT INTO BRANCHES VALUES('Odessa Branch','79760',31.8467,-102.36689,'RETAIL');
INSERT INTO BRANCHES VALUES('Houston Branch-1','77025',29.67853,-95.43044,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Decatur Branch','76234',33.24962,-97.54674,'RETAIL');
INSERT INTO BRANCHES VALUES('Lewisville Branch','75067',33.05725,-97.01165,'RETAIL');
INSERT INTO BRANCHES VALUES('Brenham Branch','77833',30.15595,-96.41905,'RETAIL');
INSERT INTO BRANCHES VALUES('Austin Branch-1','78751',30.32012,-97.71481,'RETAIL');
INSERT INTO BRANCHES VALUES('Rockdale Branch','76567',30.6503,-97.01023,'RETAIL');
INSERT INTO BRANCHES VALUES('San Antonio Branch-3','78216',29.55217,-98.48661,'RETAIL');
INSERT INTO BRANCHES VALUES('Abilene Branch-2','79605',32.4517,-99.77579,'RETAIL');
INSERT INTO BRANCHES VALUES('Cleburne Branch','76033',32.42166,-97.38356,'WHOLESALE');
INSERT INTO BRANCHES VALUES('College Station Branch','77845',30.6355,-96.30516,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Denton Branch','76210',33.14925,-97.09016,'RETAIL');
INSERT INTO BRANCHES VALUES('Alvin Branch-1','77512',29.41878,-95.24026,'RETAIL');
INSERT INTO BRANCHES VALUES('Amarillo Branch-1','79120',35.18857,-101.81719,'RETAIL');
INSERT INTO BRANCHES VALUES('Henderson Branch','75654',32.10862,-94.82693,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Paris Branch','75460',33.66771,-95.5678,'RETAIL');
INSERT INTO BRANCHES VALUES('Waxahachie Branch','75167',32.42936,-96.86103,'RETAIL');
INSERT INTO BRANCHES VALUES('Slaton Branch','79364',33.45031,-101.6518,'RETAIL');
INSERT INTO BRANCHES VALUES('Brady Branch','76825',31.13424,-99.3349,'RETAIL');
INSERT INTO BRANCHES VALUES('Fordt Worth Branch','76119',32.66555,-97.2406,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Carrollton Branch','75006',32.94441,-96.90386,'RETAIL');
INSERT INTO BRANCHES VALUES('Itasca Branch','76055',32.15944,-97.15097,'RETAIL');
INSERT INTO BRANCHES VALUES('Winnie Branch','77665',29.81749,-94.37706,'RETAIL');
INSERT INTO BRANCHES VALUES('Burkburnett Branch','73654',34.08013,-98.55913,'RETAIL');
INSERT INTO BRANCHES VALUES('Boerne Branch','78006',29.80671,-98.70248,'RETAIL');
INSERT INTO BRANCHES VALUES('Mesquite Branch','75150',32.80576,-96.62761,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Baytown Branch','77521',29.80219,-94.9955,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Orange Branch','77630',30.09311,-93.74627,'RETAIL');
INSERT INTO BRANCHES VALUES('Kaufman Branch','75142',32.58899,-96.30101,'RETAIL');
INSERT INTO BRANCHES VALUES('Frisco Branch','75034',33.08329,-96.8487,'RETAIL');
INSERT INTO BRANCHES VALUES('Portland Branch','78374',27.8892,-97.31627,'RETAIL');
INSERT INTO BRANCHES VALUES('Fort Stockton Branch','79735',30.86708,-102.84237,'RETAIL');
INSERT INTO BRANCHES VALUES('San Antonio Branch-1','78220',29.41375,-98.4102,'WHOLESALE');
INSERT INTO BRANCHES VALUES('San Angelo Branch-3','76901',31.44748,-100.494,'RETAIL');
INSERT INTO BRANCHES VALUES('Crosby Branch','77532',29.88909,-95.06142,'RETAIL');
INSERT INTO BRANCHES VALUES('Jacksonville Branch','75766',31.96639,-95.2485,'RETAIL');
INSERT INTO BRANCHES VALUES('La Grange Branch','78945',29.92131,-96.88931,'WHOLESALE');
INSERT INTO BRANCHES VALUES('Corpus Christi Branch-2','78410',27.84873,-97.63101,'RETAIL');
INSERT INTO BRANCHES VALUES('Graham Branch','76450',33.10964,-98.56536,'RETAIL');
INSERT INTO BRANCHES VALUES('Corsicana Branch','75110',32.0986,-96.44383,'WHOLESALE');
INSERT INTO BRANCHES VALUES('San Antonio Branch-2','78238',29.40633,-98.51827,'RETAIL');
INSERT INTO BRANCHES VALUES('Kenedy Branch-1','78119',28.79531,-97.85081,'RETAIL');
INSERT INTO BRANCHES VALUES('Comanche Branch','76442',31.90838,-98.59057,'RETAIL');
INSERT INTO BRANCHES VALUES('Hutto Branch','78634',30.53991,-97.56444,'RETAIL');
INSERT INTO BRANCHES VALUES('Plainview Branch','79072',34.19627以上是关于Oracle LiveLabs实验:Introduction to Oracle Spatial的主要内容,如果未能解决你的问题,请参考以下文章

Oracle LiveLabs实验:Oracle RAC Fundamentals

Oracle LiveLabs实验:Install Oracle Database 21c

Oracle LiveLabs实验:DB Security - Oracle Label Security (OLS)

Oracle LiveLabs实验:Oracle Label Security (OLS)

Oracle LiveLabs实验:Introduction to Oracle Spatial

Oracle LiveLabs实验:Introduction to Oracle Spatial