Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 2026 ADsP 시험일정
- pg_basebackup
- SQLD
- 티스토리챌린지
- Cloudy Bay Sauvignon Blanc
- 오라클
- dasp
- 복제테이블변경
- mariaDB
- SQLP
- postgresql물리백업과 복구
- PostgreSQL
- ADP시험일정
- chateau la ribaud 2018 medoc cre bourgeios
- 논리복제
- dap
- rds for oracle
- 델타복원
- 샤또 라 리보 메독 크뤼 브르주아
- 2026 ADP 시험일정
- Linux
- pgBackRest
- 물리복제
- 리눅스
- 오블완
- 물리복구
- 물리백업
- oracle
- 논리복구
- 논리백업
Archives
- Today
- Total
IT study
[Oracle] interval partition table 주기적으로 파티션 삭제하기 본문
인터벌 파티션 테이블로 생성된 테이블의 일정 보관 기간이 지나면 데이터 삭제가 필요.
oracle job 통해 배치 생성하여 주기적으로 데이터 관리 진행함
declare
cursor c_del_partition is
select object_name as tb_nm,
subobject_name as partition_nm
from ALL_OBJECTS
where owner = [스키마명]
and object_type = 'TABLE PARTITION'
and generated = 'Y' -- 시스템생성여부 : 인터벌파티션의 경우 자동생성되므로 시스템생성여부가 Y임
and ( object_name = [인터벌파티션테이블명] and created < trunc(sysdate)-10 ) ; --10일보관
;
begin
for c in c_del_partition
loop
l_ddl_str := 'alter table '||c.tb_nm||' drop partition '||c.partition_nm||'';
begin
execute immediate l_ddl_str;
exception
when others then
l_err_code := ''||SQLCODE;
l_err_msg := SQLERRM || ' ( ' || c.partition_nm || ' ) ' ;
insert into TB_ERR_LOG (wrk_tbl_nm, err_cd, err_msg) values (c.tb_nm,l_err_code,l_err_msg);
commit;
end;
end loop;
end;
all_object의 generated, created 컬럼 활용하여 삭제 대상 파티션 선정 후
파티션 삭제 진행