SPATIAL
SPATIAL is a database storage type in SQL specifically designed to store geographical or GPS data. This could include data types like Points, Lines, and Polygons, among others. Much like how INT stores integer values and CHAR stores strings, SPATIAL data types store geographical data. Operations and functions inherent to this datatype allow querying for location-based results such as proximity and layout.
Example
Output
Explanation
A table named ‘geom’ is created and a GEOMETRY type column ‘g’ is added. A POINT geometry is inserted into the ‘g’ column using the ST_GeomFromText function. The ST_AsText function is then used to retrieve the POINT geometry as a string from the ‘g’ column.
Example
Output
Explanation
The example creates a table called “places”, which includes a location text and a geom POINT
data. The POINT
data is the geo-spatial point for the place. We then inserted a row into a table, where the Tour Eiffel
is at the geo-spatial point POINT(2.2945 48.8584)
.
Finally, with the SELECT
statement, we returned both the name of the place and its geometry representation as text. The area of the Tour Eiffel was displayed along with its location point in the output.
Example
Output
Explanation
This example creates a table named SpatialTable
and inserts a row with a geography column GeogCol1
and a geometry column GeomCol1
. Both columns contain the same line string representing a spatial entity (in this case, coordinates). The SELECT
statement then retrieves and outputs the spatial data as character string using the built-in ToString()
function.
Example
Output
Explanation
The SDO_GEOMETRY
is a spatial data type in Oracle, it is used to store geometric and geographic data in two dimensions, three dimensions, and four dimensions. A Spatial index on the location
column has been created and can be used by the SDO_RELATE
function to quickly identify intersections, distances, and relationships between geometric shapes. In this case, it is used to identify places that intersect with a specified region.