SQL 错误 [1502] [72000]: ORA-01502: index ‘ROL_ID_KEY‘ or partition of such index is in unusable state

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
 
 
  1. select index_name,index_type,tablespace_name,table_type,status from user_indexes where index_name='ROL_ID_KEY';

  2. INDEX_NAME INDEX_TYPE TABLESPACE_NAME TABLE_TYPE STATUS

  3. ------------------------------ --------------------------- ------------------------------ ----------- --------

  4. 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
 
 
  1. alter session set skip_unusable_indexes=false;

  2. Session altered.

  • rebuild the invalid index alter index ROL_ID_KEY rebuild;
 
 
  1. alter index ROL_ID_KEY rebuild;

  2. Index altered.

  • Query index status
 
 
  1. select index_name,index_type,tablespace_name,table_type,status from user_indexes where index_name='ROL_ID_KEY';

  2. INDEX_NAME INDEX_TYPE TABLESPACE_NAME TABLE_TYPE STATUS

  3. ------------------------------ --------------------------- ------------------------------ ----------- --------

  4. 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.

Guess you like

Origin blog.csdn.net/weixin_45623983/article/details/130839641