Oracle - 테이블 스페이스 저장 공간 이동.

우선, 이동하고자 하는 테이블 스페이스가 사용하고 있는 데이터 파일들을 확인한다.

    SQL> SELECT ts.ts#, ts.name tsname, 
                       df.file#, df.name dfname 
             FROM v$tablespace ts, v$datafile df 
             WHERE ts.TS#=df.TS# 
                  AND ts.name='TESTTS';

       TS# TSNAME                    FILE# DFNAME
---------- -------------------- ---------- ------------------------------
        10 TESTTS                        8 /testpt/testts00.dbf
        10 TESTTS                        9 /testpt/testts01.dbf

해당 테이블 스페이스를 오프라인 상태로

    SQL> ALTER TABLESPACE  testts OFFLINE;

OS 상에서 데이터파일들을 복사한다.

     SQL> !cp /testpt/testts00.dbf /destpt/destts00.dbf
     SQL> !cp /testpt/testts01.dbf /destpt/destts01.dbf

테이블 스페이스의 이동한 데이터파일을 재정의한다. 

    SQL> ALTER TABLESPACE testts RENAME DATAFILE '/testpt/testts00.dbf' TO '/destpt/destts00.dbf'
    SQL> ALTER TABLESPACE testts RENAME DATAFILE '/testpt/testts01.dbf' TO '/destpt/destts01.dbf'

테이블 스페이스를 온라인 상태로 

    SQL> ALTER TABLESPACE testts ONLINE;

※ 테이블 스페이스를 온라인 상태로 변경할 때, 

    ERROR at line 1:
    ORA-01113: file 8 needs media recovery
    ORA-01110: data file 8: '/destpt/destts00.dbf'

이런 메세지를 출력할 수도 있다. 리커버리를 수행하자. 

    SQL> RECOVER DATAFILE 8;

    Media recovery complete.

확인.

    SQL> SELECT ts.ts#, ts.name tsname, 
                       df.file#, df.name dfname 
             FROM v$tablespace ts, v$datafile df 
             WHERE ts.TS#=df.TS# 
                 AND ts.name='TESTTS';

※ SYSTEM 테이블스페이스, 혹은 UNDO 테이블 스페이스의 데이터파일 이동은 디비가 OPEN 인 상태에서는 불가능.

by overdose | 2008/10/21 14:12 | ORACLE | 트랙백 | 덧글(1)

트랙백 주소 : http://devideby0.egloos.com/tb/2106576
☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]
Commented by 유리망치 at 2009/03/30 22:58
퍼가여

:         :

:

비공개 덧글

◀ 이전 페이지          다음 페이지 ▶