모래블로그

java.sql.SQLException: ORA-01502: index ' ' or partition of such index is in unusable state 본문

Error

java.sql.SQLException: ORA-01502: index ' ' or partition of such index is in unusable state

별모래 2023. 12. 13. 17:54
728x90

 

 

어떠한 이유로 인덱스가 깨지면 ORA-01502 오류가 발생한다고 한다.

이럴 경우, 해당 인덱스를 새로 빌드해주어야 한다.


 

해결 방법

 

1. 문제가 되는 Index 조회

select index_name, status, owner from dba_indexes where STATUS = 'UNUSABLE';

 

 

2. 문제가 되는 Index변경 Alter문 생성하여 조회

select 'alter index '||owner||'.'||index_name||' rebuild;' from dba_indexes where STATUS = 'UNUSABLE';


이 테이블에 alter index  ~~ rebuild; 형식으로 뜰 테니 그걸 복사해서


3. 생성된 Alter문 실행

alter index OWNER.INDEX_PK rebuild;

 

2번에서 생성한 Index 변경 Alter 문을 복붙해서 실행시켜주면 된다.

 

 


Reference
https://kahn5000.cafe24.com/database/oracle/o_view.html?board=oracle_t&page=4&no=541&keyfield=&key=

728x90