简体   繁体   中英

How do I write query to insert SDO_GEOMETRY type column datain Oracle DB?

I have a task to create sql queries to insert data in oracle column.
The datatype is SDO_GEOMETRY
I have only Latitude and Longitude values.

Any pointers will be helpful

The full doc has more examples but here's the snippet you need.

SDO_GEOMETRY(2001,
             4326,
             SDO_POINT_TYPE(37.783333, -122.416667, NULL),
             NULL,
             NULL)

Full Doc: https://docs.oracle.com/cd/E17781_01/appdev.112/e18750/xe_locator.htm#XELOC563

In addition to saving the Lat&Lng in the SDO_GEOMETRY column as Kris Rice said, you can use the many useful features of Oracle Spatial and Oracle Locator to achieve some useful results.

In order to use those features, the below steps must be taken:

  1. Alter the table to add a geometry (SDO_GEOMETRY) column.
  2. Update the table to populate the SDO_GEOMETRY objects using existing location-related data values.
  3. Update the spatial metadata (USER_SDO_GEOM_METADATA).
  4. Create the spatial index on the table.

The detail of the above steps is explained here .

After the above steps have been done, you can use useful operators provided by Oracle Locator. For example, you can find the locations that are within X meters distance from a given point. For more details, read this Oracle document.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM