错误现象:
今天发布脚本时,一个表插入数据时报如下错误
ORA-01502: index ‘index_name' or partition of such index is in unusable state
ORA-06512: at line 168
错误原因:
这个错误一般是因为索引状态为UNUSABLE引起的。你可以通过下面SQL,查看索引的状态
SELECT OWNER, INDEX_NAME,STATUS FROM DBA_INDEXES WHERE INDEX_NAME='INDEX_NAME'
SELECT OWNER, INDEX_NAME,STATUS FROM ALL_INDEXES WHERE INDEX_NAME='INDEX_NAME' SELECT INDEX_NAME,STATUS FROM USER_INDEXES WHERE INDEX_NAME='INDEX_NAME' 此时需要重建索引即可 ALTER INDEX INDEX_NAME REBUILD