TECH
QUESTION
자주하는 질문답변 입니다.
Oracle
작성자 | 유건데이타 | 등록일 | 2015-05-08 |
제목 | TABLE(INDEX)을 다른 TABLESPACE로 옮기는 방법(8I,ALTER TABLE .. M | ||
---|---|---|---|
TABLE(INDEX)을 다른 TABLESPACE로 옮기는 방법(8I,ALTER TABLE .. MOVE)
==================================================================== 방법은 두 가지가 있다. 첫째, "alter table X move tablespace Y" and "alter index X rebuild tablespace Y" 구문을 사용하는 것이고, 두번 째는 8 version까지 사용했던 exp/imp utility를 이용하는 것이다. (두번째 방법은 Bul : 11204, 10087 / Note : 1012307.6 참조) 본 문서에서는 첫번 째 방법만을 언급하고자 한다. 아래 script를 이용하여 tablespace 내에 있는 table / index에 대한 "Move tablespace" command를 확보한다. ----------------------- cut here ----------------------- Moveall.sql set echo off column order_col1 noprint column order_col2 noprint set heading off set verify off set feedback off set echo off spool tmp.sql select decode( segment_type, 'TABLE', segment_name, table_name ) order_col1, decode( segment_type, 'TABLE', 1, 2 ) order_col2, 'alter ' || segment_type || ' ' || segment_name || decode( segment_type, 'TABLE', ' move ', ' rebuild ' ) || chr(10) || ' tablespace &1 ' || chr(10) || ' storage ( initial ' || initial_extent || ' next ' || next_extent || chr(10) || ' minextents ' || min_extents || ' maxextents ' || max_extents || chr(10) || ' pctincrease ' || pct_increase || ' freelists ' || freelists || ');' from user_segments, (select table_name, index_name from user_indexes ) where segment_type in ( 'TABLE', 'INDEX' ) and segment_name = index_name (+) order by 1, 2 / spool off set heading on set verify on set feedback on set echo on REM UNCOMMENT TO AUTO RUN the generated commands REM ELSE edit tmp.sql, modify as needed and run it REM @tmp ------------------------------- cut here ---------------------------- 위 script를 실행함으로써, "alter table move" and "alter index rebuild" 구문을 생성할 수 있고, 더불어 storage parameter 값 또한 얻을 수 있다. 생성 구문을 보면 table 먼저 alter .. move 하고, 이후 alter index ... rebuild 작업을 수행함을 확인할 수 있다. alter table ... move 수행 결과로 index 상태가 unusable 로 변환되기 때문에 index rebuild 작업이 필요한 것이고, table의 downtime을 최소화하기 위해 필요한 조치이다. 비 교 ===== 1. "ALTER TABLE .. MOVE" 방법(A)이 기존 exp/imp 방법(B)보다 빠르고 유연성을 제공한다. 2. A 방법은 기존 objects를 drop할 필요가 없으나, B 방법은 필요하다. 3. A 방법을 사용할 때 LONG / LONG RAW datatype을 갖고 있는 table은 위 구문을 적용할 수 없다.(only B method) 4. B 방법을 사용할 때 작업 도중 변화되는 block 정보를 Oracle이 보장하지 못한다. Reference ========= 출처 : Technical Bulletin (Korean) |
Comment | |||
---|---|---|---|
등록된 코멘트가 없습니다. |