Oracle - mover indices a otro tablespace

 
Vista:

mover indices a otro tablespace

Publicado por abeltran.uy (5 intervenciones) el 13/08/2009 20:04:23
DECLARE
nom_index dba_indexes.index_name%type;

CURSOR cursor_indices IS
select index_name from dba_indexes where owner = 'OWNER_USUARIO' AND tablespace_name = 'TABLESPACE_ORIGEN';

BEGIN

OPEN cursor_indices;
LOOP
fetch cursor_indices into nom_index;
exit when cursor_indices%notfound;

BEGIN
EXECUTE IMMEDIATE 'ALTER INDEX OWNER_USUARIO.' || nom_index || ' REBUILD TABLESPACE TABLESPACE_DESTINO';

EXCEPTION
WHEN OTHERS THEN
NULL;
END;

END LOOP;
CLOSE cursor_indices;

END;
/

--La excepcion la capturo para que no dé error y se detenga cuando un indice esta bloqueado por un usuario que lo esté usando,
--de ultima a los que se estén usando los muevo depués.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder