1,在user_sdo_geom_metadata表中插入或者修改需要修改表的名称,表中的geometry字段名称和srid。具体可参考该表的字段。
INSERT INTO USER_SDO_GEOM_METADATA (table_name,column_name,DimInfo,srid)
VALUES (UPPER('TB_REALTIME_FIREDISRECORD_T'), UPPER('COORDINATES'),
MDSYS.SDO_DIM_ARRAY(
MDSYS.SDO_DIM_ELEMENT('X',114.877478378889,119.644269545556,0.005),
MDSYS.SDO_DIM_ELEMENT('Y',29.395623565556,34.655112621111,0.005)
),
8307);
2,在修改字段的srid之前,需要删除该字段上得空间索引:
drop index TB_PG_TOWERINFO_STATIONMAP_SPX;
3,使用游标遍历表中的字段,修改geometry字段的srid的值:
declare
geo sdo_geometry;
cursor pointer is
select T.STATIONMAP , T.TOWERID from DMSDKY.TB_PG_TOWERINFO t;
p pointer%rowtype;
begin
for p in pointer loop
geo := P.STATIONMAP;
if geo is not null then
if geo.sdo_srid is null then
geo.sdo_srid := 8307;
update DMSDKY.TB_PG_TOWERINFO t set T.STATIONMAP = geo where T.TOWERID = P.TOWERID;
COMMIT;
end if;
end if;
end loop;
end;
4,修改完之后再重新创建字段上得索引,注意如果字段中仍含有未修改的字段值,则会出现ora-13365错误
create index TB_PG_TOWERINFO_STATIONMAP_SPX on TB_PG_TOWERINFO t (T.STATIONMAP ) indextype is mdsys.spatial_index;
INSERT INTO USER_SDO_GEOM_METADATA (table_name,column_name,DimInfo,srid)
VALUES (UPPER('TB_REALTIME_FIREDISRECORD_T'), UPPER('COORDINATES'),
MDSYS.SDO_DIM_ARRAY(
MDSYS.SDO_DIM_ELEMENT('X',114.877478378889,119.644269545556,0.005),
MDSYS.SDO_DIM_ELEMENT('Y',29.395623565556,34.655112621111,0.005)
),
8307);
2,在修改字段的srid之前,需要删除该字段上得空间索引:
drop index TB_PG_TOWERINFO_STATIONMAP_SPX;
3,使用游标遍历表中的字段,修改geometry字段的srid的值:
declare
geo sdo_geometry;
cursor pointer is
select T.STATIONMAP , T.TOWERID from DMSDKY.TB_PG_TOWERINFO t;
p pointer%rowtype;
begin
for p in pointer loop
geo := P.STATIONMAP;
if geo is not null then
if geo.sdo_srid is null then
geo.sdo_srid := 8307;
update DMSDKY.TB_PG_TOWERINFO t set T.STATIONMAP = geo where T.TOWERID = P.TOWERID;
COMMIT;
end if;
end if;
end loop;
end;
4,修改完之后再重新创建字段上得索引,注意如果字段中仍含有未修改的字段值,则会出现ora-13365错误
create index TB_PG_TOWERINFO_STATIONMAP_SPX on TB_PG_TOWERINFO t (T.STATIONMAP ) indextype is mdsys.spatial_index;