Skip to content

Instantly share code, notes, and snippets.

@fljdin
Last active August 29, 2015 14:07
Show Gist options
  • Save fljdin/5d38a52461dea9fb778a to your computer and use it in GitHub Desktop.
Save fljdin/5d38a52461dea9fb778a to your computer and use it in GitHub Desktop.
Workaround ORA-01652 when creating function-based index on partitioned table
CREATE INDEX &schema.&index_part
ON &schema.&table_name(TO_NUMBER(TO_CHAR(TO_DATE(TO_CHAR(&column),'YYYYMMDD'),'IYYYIW')))
LOCAL UNUSABLE;
select count(1)
from dba_ind_partitions
where index_name = '&index_part' and status != 'USABLE';
DECLARE
sql_query VARCHAR2(500);
BEGIN
FOR r IN (
select rownum, 'alter index '||index_owner||'.'||index_name||' rebuild partition ' || partition_name || ' parallel(degree 4)' query
from dba_ind_partitions where index_name = '&index_part' and status != 'USABLE'
)
LOOP
execute immediate r.query;
--dbms_output.put_line(r.rownum || ': ' || r.query);
END LOOP;
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment