반응형
[오류 예제]
ORA-01502: index 'SCOTT.PK_TABLE' or partition of such index is in unusable state
ORA-01502: index 'SCOTT.PK_TABLE' or partition of such index is in unusable state
1. 문제가 되는 Index 조회
select index_name, status, owner from dba_indexes where STATUS = 'UNUSABLE';
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';
select 'alter index '||owner||'.'||index_name||' rebuild;' from dba_indexes where STATUS = 'UNUSABLE';
3. 생성된 Alter문 실행
alter index SCOTT.PK_TABLE rebuild;?
alter index SCOTT.PK_TABLE rebuild;?
--------------------------------------------
일반및 파티션테이블, sup파티션까지 조회
select *
from (
SELECT 'alter index ' || owner || '.' || index_name || ' rebuild ' || ' nologging parallel 8;' as cmd
FROM dba_indexes
WHERE STATUS = 'UNUSABLE'
AND OWNER NOT IN ('SYSTEM','SYS')
union all
SELECT 'alter index ' || index_owner || '.' || index_name || ' rebuild partition ' || partition_name || ' parallel 8;'
FROM DBA_IND_PARTITIONS
WHERE STATUS = 'UNUSABLE'
union all
select 'alter index ' || index_name || ' rebuild subpartition ' || subpartition_name || ' parallel 8;'
from dba_ind_subpartitions
where status = 'UNUSABLE'
);
일반및 파티션테이블, sup파티션까지 조회
select *
from (
SELECT 'alter index ' || owner || '.' || index_name || ' rebuild ' || ' nologging parallel 8;' as cmd
FROM dba_indexes
WHERE STATUS = 'UNUSABLE'
AND OWNER NOT IN ('SYSTEM','SYS')
union all
SELECT 'alter index ' || index_owner || '.' || index_name || ' rebuild partition ' || partition_name || ' parallel 8;'
FROM DBA_IND_PARTITIONS
WHERE STATUS = 'UNUSABLE'
union all
select 'alter index ' || index_name || ' rebuild subpartition ' || subpartition_name || ' parallel 8;'
from dba_ind_subpartitions
where status = 'UNUSABLE'
);
'DBMS > Oracle' 카테고리의 다른 글
table shrink 권고사항 확인(테이블 데이터 0건인데 용량 차지 하고 있는 테이블 실행) (0) | 2022.07.04 |
---|---|
Partition table shrink (0) | 2022.07.04 |
index rebuild 하는 방법 (0) | 2022.07.04 |
Index Primary 와 Foreign Key 관계 찾기 (0) | 2022.07.04 |
index pk(PRIMARY KEY) 인덱스 삭제 (0) | 2022.07.04 |