본 문서는 MOUNT 모드에서 Rename Datafile 명령을 실행하여 데이터파일의 이름 및 경로를 변경하는 방법을 안내합니다.
3. MOUNT모드에서 데이터파일 이름/경로 변경
3.1. 개요
DB 재기동이 필요하고 DB 복구 과정 없이 한 개 이상의 테이블스페이스의 데이터파일 혹은 SYSTEM 테이블스페이스의 데이터파일의 이름 및 경로를 변경할 수 있는 방법입니다.
데이터파일의 정보를 변경했으니 작업이 끝난 후, 컨트롤파일 백업이 필요합니다.
3.2. 절차
3.2.1. Datafile 확인
SQL> set linesize 200
SQL> col file_name for a50
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/rename/test01.dtf TEST
/home/lcj/tbdata/cjdb1/rename/test02.dtf TEST
/home/lcj/tbdata/cjdb1/test03.dtf TEST
3 rows selected.
3.2.2. DB MOUNT 기동
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]tbdown immediate
Tibero instance terminated (IMMEDIATE mode).
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]tbboot mount
Change core dump dir to /home/lcj/tibero6/bin/prof.
Listener port = 5086
Tibero 6
TmaxData Corporation Copyright (c) 2008-. All rights reserved.
Tibero instance started up (MOUNT mode).
3.2.3. 대상 Datafile 경로 변경
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1]ls test03.dtf
test03.dtf
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1]cp test03.dtf /home/lcj/tbdata/cjdb1/rename/test03.dtf
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1]cd rename
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]ls -alrt
total 1536016
drwxr-xr-x 4 lcj dba 4096 Dec 4 20:17 ..
-rw-r--r-- 1 lcj dba 1561 Dec 4 21:07 cre_ctl_1.sql
-rw------- 1 lcj dba 524288000 Dec 4 21:52 test01.dtf
-rw------- 1 lcj dba 524288000 Dec 4 21:52 test02.dtf
drwxr-xr-x 2 lcj dba 4096 Dec 4 21:54 .
-rw------- 1 lcj dba 524288000 Dec 4 21:54 test03.dtf
3.2.4. Rename Datafile 명령
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]tbsql sys/tibero
tbSQL 6
TmaxData Corporation Copyright (c) 2008-. All rights reserved.
Connected to Tibero.
SQL> alter tablespace TEST rename datafile '/home/lcj/tbdata/cjdb1/test03.dtf' TO
'/home/lcj/tbdata/cjdb1/rename/test03.dtf';
Tablespace 'TEST' altered.
3.2.5. DB 재기동
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]tbdown immediate
Tibero instance terminated (IMMEDIATE mode).
[lcj@finlin:cj1:/home/lcj/tbdata/cjdb1/rename]tbboot
Change core dump dir to /home/lcj/tibero6/bin/prof.
Listener port = 5086
Tibero 6
TmaxData Corporation Copyright (c) 2008-. All rights reserved.
Tibero instance started up (NORMAL mode).
3.2.6. 작업 확인 및 controlfile 백업
SQL> set linesize 200
SQL> col file_name for a50
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/rename/test01.dtf TEST
/home/lcj/tbdata/cjdb1/rename/test02.dtf TEST
/home/lcj/tbdata/cjdb1/rename/test03.dtf TEST
3 rows selected.
SQL> alter database backup controlfile to trace as '/home/lcj/tbdata/cjdb1/rename/cre_ctl_3.sql'
reuse noresetlogs;
Database altered.