Table of Contents

Oracle Spatial - Geometry Metadata Views and Index

About

The geometry metadata describe for each dimensions (axis):

This data are stored in a global table owned by MDSYS (which users should never directly update).

Once the metadata are filled, you can and must create the index.

Just for info: for the coordinate systems metadata (and then not the geometry metadata), the coordinate systems functions and procedures use information provided in the tables and views supplied with Oracle Spatial. The tables and views are part of the MDSYS schema; however, public synonyms are defined, so you do not need to specify MDSYS. before the table or view name. All tables are explained in this paragraph from the user guide.

Metadata

Views

Each Spatial user has the following views available in the schema associated with that user:

Spatial users are responsible for populating these views. For each spatial column, you must insert an appropriate row into the USER_SDO_GEOM_METADATA view.

Oracle Spatial ensures that the ALL_SDO_GEOM_METADATA view is also updated to reflect the rows that you insert into USER_SDO_GEOM_METADATA.

View Definition

Each metadata view has the following definition:

(
  TABLE_NAME   VARCHAR2(32),
  COLUMN_NAME  VARCHAR2(32),
  DIMINFO      SDO_DIM_ARRAY,
  SRID         NUMBER
);

where:

DIMINFO

The DIMINFO column (Dimension info):

The SDO_DIM_ARRAY type is defined as follows:

Create Type SDO_DIM_ARRAY as VARRAY(4) of SDO_DIM_ELEMENT; 

Create Type SDO_DIM_ELEMENT as OBJECT (
  SDO_DIMNAME VARCHAR2(64),
  SDO_LB NUMBER,
  SDO_UB NUMBER,
  SDO_TOLERANCE NUMBER);

The SDO_DIM_ARRAY instance is of size n if there are n dimensions. Example, DIMINFO contains :

Each SDO_DIM_ELEMENT instance in the array must have valid (not null) values for the:

Example

SQL

INSERT INTO user_sdo_geom_metadata
    (TABLE_NAME,
     COLUMN_NAME,
     DIMINFO,
     SRID)
  VALUES (
  'cola_markets',
  'shape',
  SDO_DIM_ARRAY(   -- 20X20 grid
    SDO_DIM_ELEMENT('MyDimension1', 0, 20, 0.005),
    SDO_DIM_ELEMENT('MyDimension2', 0, 20, 0.005)
     ),
  NULL   -- SRID
);
-- Set up the metadata entry for this table.
-- note that the column name sets up the function on top
-- of the two columns used in this function,
-- along with the owner of the function.
insert into user_sdo_geom_metadata values(
   'LONG_LAT_TABLE', -- table
   'scott.get_long_lat_pt(longitude,latitude)', -- function
   mdsys.sdo_dim_array(
      mdsys.sdo_dim_element('Longitude', -180, 180, 0.005),
      mdsys.sdo_dim_element('Latitude', -90, 90, 0.005)
   ),
   8307  -- SRID
    );
insert into USER_SDO_GEOM_METADATA values (
        'MY_TABLE', -- Table
        'MY_COLUMN', -- Column of type SDO_GEOMETRY
        MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('Longitude', -180, 180, 10), -- 10 meters tolerance
                            MDSYS.SDO_DIM_ELEMENT('Latitude', -90, 90, 10)), -- 10 meters tolerance
        8307); -- SRID for 'Longitude / Latitude (WGS 84)' coordinate system
);

commit;

CREATE INDEX MY_TABLE_sdx
   ON MY_TABLE(MY_COLUMN)
   INDEXTYPE IS MDSYS.SPATIAL_INDEX;

SQL Developer

The same example than above but from SQL Developer.

Sql Developer Update Spatial Metadata

Support

ORA-13203: failed to read USER_SDO_GEOM_METADATA view

This error occurs when you try to create an index. It says that it miss something in the metadata. You have forgotten to add an entry in the metadata USER_SDO_GEOM_METADATA