Shrink 세그먼트
DB CAFE
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
스토리지 용량 관리를 위해 Shrink 기능을 수행한다. 사용법은 아래의 순서대로 진행 된다.
1. 현재 임계치(Threshold) 값 확인하기.
SQL> select warning_value, critical_value from dba_thresholds
where metrics_name='Tablespace Space Usage'
and object_name is null;
2. 임계치 경고 메시지 확인하기.
SQL> select reason, message_level from dba_outstanding_alerts
where object_name='TBSALERT';
3. 현재 사용하고 있는 블럭수와 HWM를 확인한다.
SQL> select count(distinct dbms_rowid.rowid_block_number(rowid)) blocks from emp;
-> 실제 사용하고 있는 블럭수를 출력한다.
SQL> select blocks, extents from user_segments where segment_name='EMP';
-> HWM(High Water Mark, 사용된 블럭과 사용하지 않은 블럭의 경계선)이 할당된 블럭수 출력
4. 낭비되고 있는 영역 조각모음하기.
SQL> alter table emp ENABLE ROW MOVEMENT;
-> row id가 바뀔수 있기에 행이주를 허용한다.
SQL> alter table emp shrink space compact;
-> 실제 사용 하는 블럭만 정리한다. HWM는 앞당겨 지지 않는다.
SQL> alter table emnp shrink space;
-> 블러과 HWM까지 정리한다.
이후 3번 작업을 다시하여 Shrink 작업 전후를 비교해 본다..