기술 정보
home
채널 소개
home

Tablespace offline 상태에서 Datafile 이름 및 경로 변경 방법

문서 유형
기술 정보
분야
설치
키워드
Tablespace offline
Datafile
1 more property

개요

DB 재기동 없이 데이터파일의 이름 또는 경로를 변경하는 방법을 안내합니다.
해당 작업은 대상 데이터파일이 포함된 Tablespace를 offline 상태로 변경한 후, RENAME DATAFILE 명령어를 실행하여 데이터파일의 이름 혹은 경로를 변경합니다.
이때 Tablespace는 non-SYSTEM이어야 offline 상태로 변경할 수 있습니다.
해당 작업 이후, Datafile의 정보가 변경되므로 반드시 컨트롤파일 백업을 수행해야 합니다.

방법

아래 절차와 같이 변경 작업을 진행합니다.

1. Data file, Table space 확인

SQL> set linesize 200 SQL> col file_name for a40 SQL> col tablespace_name for a20 SQL> select file_name, tablespace_name from dba_datafiles where file_name like '%test0_.dtf'; FILE_NAME TABLESPACE_NAME ---------------------------------------- -------------------- /home/lcj/tbdata/cjdb1/test01.dtf TEST /home/lcj/tbdata/cjdb1/test02.dtf TEST /home/lcj/tbdata/cjdb1/test03.dtf TEST 3 rows selected.
SQL
복사

2. 대상 Tablespace를 Offline 상태로 변경

SQL> alter tablespace TEST offline; Tablespace 'TEST' altered. SQL> select tablespace_name, status from dba_tablespaces where tablespace_name = 'TEST'; TABLESPACE_NAME STATUS -------------------- ------------- TEST OFFLINE 1 row selected.
SQL
복사

3. 대상 Datafile 경로 변경

[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1]ls test01.dtf test01.dtf [lcj@finlin:cj1:/home/lcj/tbdata/cjdb1]cp test01.dtf /home/lcj/tbdata/cjdb1/rename/test01.dtf [lcj@finlin:cj1:/home/lcj/tbdata/cjdb1]cd rename [lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]ls test01.dtf test01.dtf
SQL
복사

4. Rename Datafile 명령

SQL> alter tablespace TEST rename datafile '/home/lcj/tbdata/cjdb1/test01.dtf' TO '/home/lcj/tbdata/cjdb1/rename/test01.dtf'; Tablespace 'TEST' altered.
SQL
복사

5. 대상 Tablespace를 Online 상태로 전환

SQL> alter tablespace TEST online; Tablespace 'TEST' altered.
SQL
복사

6. 작업 확인 및 Controlfile 백업

SQL> select file_name, tablespace_name from dba_datafiles where tablespace_name='TEST'; FILE_NAME TABLESPACE_NAME -------------------------------------------- -------------------- /home/lcj/tbdata/cjdb1/rename/test01.dtf TEST /home/lcj/tbdata/cjdb1/test02.dtf TEST /home/lcj/tbdata/cjdb1/test03.dtf TEST 3 rows selected. SQL> alter database backup controlfile to trace as '/home/lcj/tbdata/cjdb1/rename/cre_ctl_1.sql' reuse noresetlogs; Database altered. [lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]ls -alrt total 512016 drwxr-xr-x 4 lcj dba 4096 Dec 4 20:17 .. -rw------- 1 lcj dba 524288000 Dec 4 20:26 test01.dtf drwxr-xr-x 2 lcj dba 4096 Dec 4 20:35 . -rw-r--r-- 1 lcj dba 1554 Dec 4 20:35 cre_ctl_1.sql
SQL
복사