database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
ㆍOracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Oracle Tutorials 9256 게시물 읽기
 News | Q&A | Columns | Tutorials | Devel | Files | Links
No. 9256
TABLE(INDEX)을 다른 TABLESPACE로 옮기는 방법(8I,ALTER TABLE .. MOVE)
작성자
정재익(advance)
작성일
2002-01-05 15:41
조회수
6,040

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이 보장하지 못한다.

[Top]
No.
제목
작성자
작성일
조회
92599i spfile 생성 및 수정 예제
정재익
2002-01-05
5983
9258그림 화일 연동 (bfile,blob in oas)예제
정재익
2002-01-05
6874
9257단.복수의 오라클 엔진에 db복사
정재익
2002-01-05
5156
9256TABLE(INDEX)을 다른 TABLESPACE로 옮기는 방법(8I,ALTER TABLE .. MOVE)
정재익
2002-01-05
6040
9255CLOB COLUMN을 조회하는 방법
정재익
2002-01-05
6779
9254TABLE SEGMENT/EXTENT 내의 FREE SPACE/USED SPACE USAGE 확인 방법
정재익
2002-01-05
5127
9253LONG RAW DATA(IMAGE) 를 INSERT, SELECT 하기
정재익
2002-01-05
16122
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2023 DSN, All rights reserved.
작업시간: 0.049초, 이곳 서비스는
	PostgreSQL v16.1로 자료를 관리합니다