How would I disable and later enable all indexes in a given schema/database in Oracle?
Note: This is to make sqlldr run faster.
How would I disable and later enable all indexes in a given schema/database in Oracle?
Note: This is to make sqlldr run faster.
combining 3 answers together: (because a select statement does not execute the DDL)
Do import...
Note this assumes that the import is going to happen in the same (sqlplus) session.
If you are calling "imp" it will run in a separate session so you would need to use "ALTER SYSTEM" instead of "ALTER SESSION" (and remember to put the parameter back the way you found it.
Combining the two answers:
First create sql to make all index unusable:
Do import...
You should try sqlldr's SKIP_INDEX_MAINTENANCE parameter.
From here: http://forums.oracle.com/forums/thread.jspa?messageID=2354075
alter session set skip_unusable_indexes = true;
alter index your_index unusable;
do import...
alter index your_index rebuild [online];
If you're on Oracle 11g, you may also want to check out dbms_index_utl.
If you are using non-parallel direct path loads then consider and benchmark not dropping the indexes at all, particularly if the indexes only cover a minority of the columns. Oracle has a mechanism for efficient maintenance of indexes on direct path loads.
Otherwise, I'd also advise making the indexes unusable instead of dropping them. Less chance of accidentally not recreating an index.