ORA-01502: index 'indexname' or partition of such index is in unusable state
The reason is that some indexes has been marked unusable by a direct load or by a DDL operation, or shrinking space etc. Here is simple solution.
- Drop the specified index and/or recreate the index
- Rebuild the specified index
- Rebuild the unusable index partition
Here we rebuilding UNUSABLE indexes onling, quering to USER_INDEXES view.
$sqlplus /nologSql> connect system/oracle
Sql> SELECT count(*),status FROM all_indexes GROUP BY status;
Sql> SELECT 'alter index 'table_owner'.'index_name' rebuild online ;' FROM all_indexes where status='UNUSABLE' ORDER BY table_owner
Just execute sql statement output, it will rebuild all unused indexes.