SELECT 'ALTER INDEX ' || OWNER || '.' || segment_name || ' REBUILD TABLESPACE ' || 'TBS_INDEX' || ';'
FROM dba_segments
WHERE OWNER <> 'EXPLOIT'
AND segment_type = 'INDEX'
AND tablespace_name like '%DATA'
UNION
SELECT 'ALTER TABLE ' || OWNER || '.' || segment_name || ' MOVE TABLESPACE ' || 'TBS_DATA' || ';'
FROM dba_segments
WHERE OWNER <> 'EXPLOIT'
AND segment_type = 'TABLE'
AND tablespace_name like '%INDEX';