admin

在oracle上创建空间索引

sql

我有一个表“ floating_options”,我想在列“ area_geo”(这是一个sdo_geometry列,其中有两行数据,当我从
floating_options中选择
时出现)上创建空间索引。

我使用了以下代码,但收到以下错误。我将非常感谢您的帮助!谢谢!

CREATE INDEX area_idx ON floating_options(area_geo)
   INDEXTYPE IS MDSYS.SPATIAL_INDEX;


Error report -
SQL Error: ORA-29855: error occurred in the execution of ODCIINDEXCREATE routine
ORA-13203: failed to read USER_SDO_GEOM_METADATA view
ORA-13203: failed to read USER_SDO_GEOM_METADATA view
ORA-06512: at "MDSYS.SDO_INDEX_METHOD_10I", line 10
29855. 00000 -  "error occurred in the execution of ODCIINDEXCREATE routine"
*Cause:    Failed to successfully execute the ODCIIndexCreate routine.
*Action:   Check to see if the routine has been coded correctly.

阅读 275

收藏
2021-07-01

共1个答案

admin

在索引表之前,应先对其进行“空间启用”。
尝试检查它是否显示在空间元数据中:

SELECT * FROM USER_SDO_GEOM_METADATA
    WHERE TABLE_NAME = UPPER('floating_options')
      AND COLUMN_NAME = UPPER('area_geo');

如果没有结果-则有两个选项可用。
一种肮脏的方式-直接插入数据

INSERT INTO USER_SDO_GEOM_METADATA
VALUES (UPPER('floating_options'),UPPER('area_geo'),
        mdsys.SDO_DIM_ARRAY(
             mdsys.SDO_DIM_ELEMENT('Easting', <lowest_x>, <highest_x>, <x_tolerance>),
             mdsys.SDO_DIM_ELEMENT('Northing', <lowest_y>, <highest_y>, <y_tolerance>)
        ), <SRID>);

请相应地更改< 占位符 >

请同时查看https://community.oracle.com/thread/836452?tstart=0
http://gerardnico.com/wiki/oracle_spatial/metadata

2021-07-01