Oracle重建用户下同一表空间的所有索引

declare
  STR VARCHAR2(400);
begin
  -- 重建ORACLE索引-
  FOR TMP_IDX IN (SELECT TABLESPACE_NAME,  TABLE_NAME, INDEX_NAME
                    FROM user_indexes
                   WHERE  temporary = 'N' AND INDEX_NAME not like '%$%')
                LOOP
    STR := 'ALTER INDEX '|| TMP_IDX.INDEX_NAME ||' Rebuild';
    EXECUTE IMMEDIATE STR;
  END LOOP;
end;

你可能感兴趣的:(oracle)