Sometimes, when the disk space is full and part of the tablespace or data files need to be migrated to the location, we will introduce three methods to move the data file next time. The same is true for moving the tablespace.
1. Use the OS MV mode.
2. Use the backup as copy method.
3. Use RESTORE
The steps for each method are as follows:
1. Use the OS MV Mode
- 1.1 System for viewing data files
- SQL> @ files. SQL
- Type Tablspace Filename File Size Status Sequence Arch
- --------------------------------------------------------------------------------------------------------------------------------
- Data TEST1 D: \ APP \ LUOPING \ ORADATA \ WINORCL \ TEST1.DBF 10,485,760 Available 0
- 1.2 put the data file OFFLINE
- SQL> alter tablespace test1 offline;
- The tablespace has been changed.
- SQL> host mv D: \ APP \ LUOPING \ ORADATA \ WINORCL \ TEST1.DBF D: \ APP \ LUOPING \ ORADATA \ WINORCL \ TEST2.DBF
- 1.3 modify the data file path
- SQL> alterdatabase rename file 'd: \ APP \ LUOPING \ ORADATA \ WINORCL \ TEST1.DBF 'to 'd: \ APP \ LUOPING \ ORADATA \ WINORCL \ TEST2.DBF ';
- The database has been changed.
- 1.4 online file
- SQL> alter tablespace test1 online;
- The tablespace has been changed.
- 1.5 view the modified path
- SQL> @ files. SQL
- Type Tablspace Filename File Size Status Sequence Arch
- --------------------------------------------------------------------------------------------------------------------------------
- Data TEST1 D: \ APP \ LUOPING \ ORADATA \ WINORCL \ TEST2.DBF 10,485,760 Available 0
- The modification has been completed successfully.