Professional Documents
Culture Documents
Spatial Queries: Oracle Corporation, 2002. All Rights Reserved
Spatial Queries: Oracle Corporation, 2002. All Rights Reserved
Spatial Queries
Exact
Secondary Result
Primary Set
Filter
Spatial Layer Filter Reduced
Data Data Set Spatial Exact
Spatial Index Result
Functions
Set
sdo_level = 2
• SDO_NN
– Returns nearest neighbors
• GEOMETRY-2
– Variable or column in a table
– Must be of type SDO_GEOMETRY
– If querytype=JOIN, must be a column in a table and indexed
(very rare) with same index type (Quadtree/Rtree) and
SDO_LEVEL (if Quadtree)
• QUERYTYPE
– Valid values are WINDOW or JOIN (very rare)
Copyright Intergraph Hong Kong Limited, ®
• LAYER_GTYPE
– Set to POINT if querying POINT only
columns (for optimal performance,
quadtree indexes only)
– Otherwise, NOTPOINT (default)
Hint #1: All Spatial operators return TRUE or FALSE. When writing
spatial queries always test with = 'TRUE', never <> 'FALSE' or
= 'true'
Copyright Intergraph Hong Kong Limited, ®
B
B
Contains Covers
Touch
Inside Covered by
A A A red B green
B
B
Overlap Overlap
Boundaries Intersect Boundaries Disjoint Equal
A
Disjoint
Contains B B
Inside
Touch
Covers
Covered by
A
B
A
B
Overlap Overlap
Boundaries Intersect Boundaries Disjoint
A
Disjoint
On B
• MASK
– Identify spatial relationship to test
– Must be UPPER CASE in 8.1.5, case doesn’t
matter in 8.1.6+
– OR’ed masks do not work in 8.1.5, fixed in
8.1.6+ (i.e. INSIDE+COVEREDBY)
• QUERYTYPE
– Valid values are WINDOW or JOIN (very rare)
• LAYER_GTYPE
– Set to POINT if querying POINT only columns
(for optimal performance)
– Otherwise, NOTPOINT (default)
– Currently applicable only to Quadtree indexes
'mask=ANYINTERACT
querytype=JOIN
LAYER_GTYPE=POINT') = 'TRUE';
**NOTE** In 8.1.6 and higher analyzing and computing statistics on
both the index tables help the execution plan of a join query.
Do not analyze the index tables in 8.1.5.
COUNTY RELATIONSHIP
------------------------------- --------------
Atlantic COVERS
Cape May COVERS
Cumberland COVERS
Essex CONTAINS
COUNTY RELATIONSHIP
------------------------------- --------------
Atlantic COVEREDBY
Cape May COVEREDBY
Cumberland COVEREDBY
Essex INSIDE
Copyright Intergraph Hong Kong Limited, ®
SELECT *
FROM TABLE (SELECT a.geom.sdo_ordinates
FROM states a
WHERE a.state = 'California');
SELECT *
FROM TABLE (SELECT a.geom.sdo_elem_info
FROM states a
WHERE a.state = 'California');