Oracle Spatial Introduction

Source: Internet
Author: User
Tags create index insert
Oracle
Oracle Spatial Profile:
First, Oracle supports custom data types, and you can use arrays, structs, or classes with constructors, functional functions to define your own object types. Such an object type can be used for the data type of the property column, or it can be used to create the object table. Oracle spatial is also a set of spatial data processing systems developed on the basis of this feature.
Spatial has a number of custom data types, all under the Mdsys scheme, often using the sdo_geometry type. Sdo_geometry represents a geometric object that can be a point, line, surface, multi point, multi-line, faceted, or mixed object.
Spatial index of R-Tree and four-fork tree Spatial index are realized based on this data type, and many spatial analysis functions are realized in the form of SQL function.

Oracle Spatial uses:
1, the Sdo_geometry data type as a column of the datasheet.

CREATE TABLE Cola_markets (
mkt_id number PRIMARY KEY,
Name VARCHAR2 (32),
Shape Mdsys. Sdo_geometry);

2, fill in the space metadata data.

INSERT into User_sdo_geom_metadata
VALUES (
' Cola_markets ',
' Shape ',
Mdsys. Sdo_dim_array (--20x20 grid
Mdsys. Sdo_dim_element (' X ', 0, 20, 0.005),
Mdsys. Sdo_dim_element (' Y ', 0, 20, 0.005)
),
NULL--SRID
);

3, create spatial index.

CREATE INDEX Cola_spatial_idx
On Cola_markets (SHAPE)
Indextype is Mdsys. Spatial_index;

At this point, the creation of a spatial data table is officially completed.

4. Insert spatial data. The insertion of spatial data should be

INSERT into Cola_markets VALUES (
2,
' Cola_b ',
Mdsys. Sdo_geometry (
2003,--2-dimensional polygon
Null
Null
Mdsys. Sdo_elem_info_array (1,1003,1), one polygon (exterior polygon ring)
Mdsys. Sdo_ordinate_array (5,1, 8, 1, 8, 6, 5, 7, 5,1)
)
);

5, the Spatial Analysis query example.

--Return the topological difference of two geometries.
SELECT Sdo_geom. Sdo_difference (C_a.shape, M.diminfo, C_c.shape, M.diminfo)
From Cola_markets c_a, Cola_markets C_c, User_sdo_geom_metadata m
WHERE m.table_name = ' cola_markets ' and m.column_name = ' SHAPE '
and c_a.name = ' cola_a ' and c_c.name = ' cola_c ';


The eight winds are not moving November 23, 2004 graffiti in Dalian


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.