Document Type | Technical Information
Category | Administration
Applicable Product Versions | 6FS07, 7FS02
Document Number | TADTI053
Overview
This document explains three methods that can be performed to modify the filename or change the path of a datafile.
- Method without modifying the control file
- Modify and regenerate the control file
- Tablespace offline
Each method can be selectively used depending on the environment and purpose.
Method
1. Method without modifying the control file
1) Shut down Tibero
tbdown immediate
2) Copy the datafile
Copy the existing datafile to the desired name or path.
$ cp /home/tibero/oldfile.dtf /home/tibero/newfile.dtf
3) Switch to mount mode
tbboot mount
4) Connect to SQL
Connect using the SYS account.
tbsql sys/tibero
5) Rename the datafile
ALTER DATABASE RENAME FILE '/home/tibero/oldfile1.dtf' TO '/home/tibero/newfile1.dtf'; ALTER DATABASE RENAME FILE '/home/tibero/oldfile2.dtf' TO '/home/tibero/newfile2.dtf';
6) Shut down Tibero
tbdown immediate
7) Start Tibero
tbboot
2. Modify and regenerate the control file
1) Backup control file creation script (normal mode)
tbsql sys/tibero SQL> ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/data/ctl.sql' REUSE NORESETLOGS;
2) Shut down Tibero
tbdown immediate
3) Copy the datafile
Copy the existing datafile to the desired name or path.
$ cp /home/tibero/oldfile.dtf /home/tibero/newfile.dtf
4) Modify the control file creation script
Modify the relevant filename in the control file creation script backed up in step 1.
...
NORESETLOGS
DATAFILE
'/home/tibero/system001.dtf',
...
'/home/tibero/oldfile.dtf', โ '/home/tibero/newfile.dtf '
...5) Switch to nomount mode
tbboot nomount
6) Connect to SQL
tbsql sys/tibero
7) Regenerate the control file
SQL> @/data/ctl.sql
8) Shut down Tibero
tbdown
9) Switch to mount mode
tbboot mount
10) Perform recovery
SQL> alter database recover automatic;
11) Shut down Tibero
tbdown
12) Start Tibero
tbboot
13) Regenerate TEMPFILE
Regenerate the tempfile using the temp creation script in the control file creation script.
...
---- Adding Tempfiles is required in OPEN mode.
-- ALTER TABLESPACE TEMP ADD TEMPFILE '/home/tibero/temp001.dtf'
-- SIZE 100M REUSE AUTOEXTEND ON NEXT 16M MAXSIZE 3G;
...
SQL > ALTER TABLESPACE TEMP ADD TEMPFILE '/home/tibero/temp001.dtf' SIZE 100M REUSE AUTOEXTEND ON NEXT 16M MAXSIZE 3G;
Tablespace offline
1) Set tablespace offline
Switch the tablespace containing the relevant datafile to offline status.
SQL> alter tablespace tablespace_name offline;
2) Copy the datafile
Copy the existing datafile to the desired name or path.
$ cp /home/tibero/oldfile.dtf /home/tibero/newfile.dtf
3) Rename the datafile
SQL> ALTER DATABASE RENAME FILE '/home/tibero/oldfile.dtf' TO '/home/tibero/newfile.dtf';
4) Set tablespace online
SQL> alter tablespace tablespace_name online;
Note
Method 3 has the advantage that it can be performed without shutting down the database in normal mode, but it can only be safely performed if there are absolutely no transactions accessing the tablespace. Therefore, it is difficult to perform in an actual production environment.
Also, if the tablespace offline does not succeed properly, datafile issues may occur, so it is recommended to use method 1 or 2 rather than method 3.