-- This example demonstrates how to use SE_SpatialKey to build
-- an R-Tree index on a clustered table.

-- Step 1. Create the cities table which will contains the names 
-- and locations of world cities.

CREATE TABLE cities (name varchar(255),
                     locn ST_Point);

-- Step 2. Populate this table with data from a DB-Access load file.
-- This data file is included with the Spatial DataBlade Module as 
-- part of this example.  It contains the names and locations of
-- approximately 300 world cities.

LOAD FROM cities.load INSERT INTO cities;

-- Step 3. Create a clustered functional btree index.

CREATE CLUSTER INDEX cbt_idx ON cities (SE_SpatialKey(locn));

-- Step 4. Create an R-Tree index with the "NO_SORT" option.

CREATE INDEX locn_idx ON cities (locn ST_Geometry_ops)
  USING RTREE (BOTTOM_UP_BUILD='yes', NO_SORT='yes');

-- Step 5. Drop the btree index.

DROP INDEX cbt_idx;
