When inserting data, the following error is reported:
SQL error [1502] [72000]: ORA-01502: index 'ROL_ID_KEY' or partition of such index is in unusable state
This error is caused by the failure of the index . After rebuilding the index, the problem will be solved up.
The process is as follows:
- Check index status
-
select index_name,index_type,tablespace_name,table_type,status from user_indexes where index_name='ROL_ID_KEY';
-
INDEX_NAME INDEX_TYPE TABLESPACE_NAME TABLE_TYPE STATUS
-
------------------------------ --------------------------- ------------------------------ ----------- --------
-
ROL_ID_KEY NORMAL DATA_DYNAMIC TABLE UNUSABLE
At this time the index is already "UNUSABLE"
- Set
skip_unusable_indexes=false
, in order not to skip invalid indexes
-
alter session set skip_unusable_indexes=false;
-
Session altered.
- rebuild the invalid index
alter index ROL_ID_KEY rebuild;
-
alter index ROL_ID_KEY rebuild;
-
Index altered.
- Query index status
-
select index_name,index_type,tablespace_name,table_type,status from user_indexes where index_name='ROL_ID_KEY';
-
INDEX_NAME INDEX_TYPE TABLESPACE_NAME TABLE_TYPE STATUS
-
------------------------------ --------------------------- ------------------------------ ----------- --------
-
ROL_ID_KEY NORMAL DATA_DYNAMIC TABLE VALID
At this point, the index status has been changed to 'VALID', and the error is resolved. Now execute sql, inserting data will not report an error.