accept ts_ind prompt 'Informe a Tablespace de Indices:'
col owner format a10
col segment_name format a25
col tablespace_name format a20
set linesize 200
set pagesize 1000

SET HEADING OFF
SELECT 'ALTER INDEX '|| Owner||'.'|| segment_name || CHR(10) ||
       'REBUILD TABLESPACE ' || UPPER( '&TS_IND' ) || ';'
FROM dba_segments
WHERE segment_type like '%INDEX%'
and owner not in ( 'SYS', 'SYSTEM')
and tablespace_name != UPPER( '&TS_IND' );

SET HEADING ON FEEDBACK ON

hostgator