Skip to content

Instantly share code, notes, and snippets.

@lud
Created June 19, 2014 15:18
Show Gist options
  • Save lud/e40ee6288a1e72cd3baf to your computer and use it in GitHub Desktop.
Save lud/e40ee6288a1e72cd3baf to your computer and use it in GitHub Desktop.
Recreate Oracle Spatial indexes
DECLARE
TYPE curs IS REF CURSOR;
c curs;
q varchar2(200);
idx VARCHAR(200);
tab VARCHAR(200);
col VARCHAR(200);
BEGIN
q := 'select index_name,table_name,column_name from user_sdo_index_info';
OPEN c FOR q;
LOOP
FETCH c into idx,tab,col;
EXIT WHEN c%NOTFOUND;
SYS.dbms_output.put('Supression de l''index ' || idx || ' sur ' || tab);
execute immediate 'drop index ' || idx;
SYS.dbms_output.put_line(' ok');
SYS.dbms_output.put('Création de l''index ' || idx || ' sur ' || tab);
execute immediate 'create index ' || idx || ' on ' || tab || '(' || col || ') INDEXTYPE IS mdsys.spatial_index';
SYS.dbms_output.put_line(' ok');
END LOOP;
CLOSE c;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment