Tuesday, March 01, 2011

Update Oracle Spatial Metadata and create Spatial Index

Update USER_SDO_GEOM_METADATA
Before update SDO_GEOM_METADATA, I got to know the MBR
SELECT SDO_AGGR_MBR(location) FROM dem;
or for this , I use

SQL> SELECT MIN(x), MAX(x), MIN(y), MAX(y), MIN(z), MAX(z) FROM dem;


    MIN(X)     MAX(X)     MIN(Y)     MAX(Y) MIN(Z)     MAX(Z)
---------- ---------- ---------- ---------- ---------- ----------
119.982565  122.02683 21.8673002 25.3523955 0          4145

Use this information to update USER_SDO_GEOM_METADATA
SQL> INSERT INTO USER_SDO_GEOM_METADATA
  2  VALUES ('DEM','LOCATION',
  3  SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X',119.982565,122.02683,10),
  4  SDO_DIM_ELEMENT('Y',21.8673002,25.3523955,10)),4326);

1 row created.
SQL> commit;
Commit complete.


Now, it's time to create spatial index
SQL> CREATE INDEX sdo_dem_location ON dem (location)
  2  INDEXTYPE IS MDSYS.SPATIAL_INDEX;

No comments: