1. Oracle 12c introduced the ability to move datafiles online using the ALTER DATABASE command, allowing datafile movement without putting the tablespace in read-only mode or experiencing downtime.
2. The command ALTER DATABASE MOVE DATAFILE 'filename' TO 'new_filename' allows moving a datafile to a new location while queries and DML continue.
3. Parameters like REUSE and KEEP control whether the original datafile is overwritten or preserved during an online datafile move.
1. Oracle 12c introduced the ability to move datafiles online using the ALTER DATABASE command, allowing datafile movement without putting the tablespace in read-only mode or experiencing downtime.
2. The command ALTER DATABASE MOVE DATAFILE 'filename' TO 'new_filename' allows moving a datafile to a new location while queries and DML continue.
3. Parameters like REUSE and KEEP control whether the original datafile is overwritten or preserved during an online datafile move.
1. Oracle 12c introduced the ability to move datafiles online using the ALTER DATABASE command, allowing datafile movement without putting the tablespace in read-only mode or experiencing downtime.
2. The command ALTER DATABASE MOVE DATAFILE 'filename' TO 'new_filename' allows moving a datafile to a new location while queries and DML continue.
3. Parameters like REUSE and KEEP control whether the original datafile is overwritten or preserved during an online datafile move.
1. Oracle 12c introduced the ability to move datafiles online using the ALTER DATABASE command, allowing datafile movement without putting the tablespace in read-only mode or experiencing downtime.
2. The command ALTER DATABASE MOVE DATAFILE 'filename' TO 'new_filename' allows moving a datafile to a new location while queries and DML continue.
3. Parameters like REUSE and KEEP control whether the original datafile is overwritten or preserved during an online datafile move.
Prior to Oracle 12c, moving datafiles has always been an offline task. There were certain techniques you could employ to minimize that downtime, but you couldn't remove it completely. Oracle 12c includes an enhancement to the ALTER DATABASE command to allow datafiles to be moved online. 1. 2. 3. 4. 5. 6.
No need to put tablespace to read only
ALTER DATABASE MOVE DATAFILE old1.dbf' TO new1.dbf'; Queries and DML can continue Great for ASM conversions Use REUSE at the end, if you want to overwrite If you want to keep the old one, use KEEP at the end
Step-1: Login as sysdba and startup the database
[oracle@localhost ~]$ sqlplus /nolog SQL> connect sys/oracle as sysdba SQL> startup; SQL> set linesize 150 SQL> set pagesize 10000 SQL> set serveroutput on SQL> column name format a70 SQL> select name,status from v$datafile where name like '%file_to_move%'; NAME STATUS -------------------------------------------------------------------------------------------------------------/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move01.dbf ONLINE SQL> !ls -l /u01/app/oracle/oradata/ORCL/datafile/ total 1590356 -rw-r-----. 1 oracle oinstall 744497152 Nov 3 10:39 o1_mf_sysaux_b53spns0_.dbf -rw-r-----. 1 oracle oinstall 807411712 Nov 3 10:39 o1_mf_system_b53ss9xf_.dbf -rw-r-----. 1 oracle oinstall 62922752 Nov 3 10:07 o1_mf_temp_b53swdsp_.tmp -rw-r-----. 1 oracle oinstall 57679872 Nov 3 10:39 o1_mf_undotbs1_b53svd7h_.dbf -rw-r-----. 1 oracle oinstall 5251072 Nov 3 10:04 o1_mf_users_b53svc3r_.dbf -rw-r-----. 1 oracle oinstall 10493952 Nov 3 10:04 tbs_file_to_move01.dbf
Online Datafile Movement
Page 1 of 5
SQL> alter database move datafile
'/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move01.dbf' to '/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move02.dbf'; Database altered.
Online Datafile Movement
Page 2 of 5
SQL> select name,status from v$datafile where name like '%file_to_move%';
NAME STATUS -------------------------------------------------------------------------------------------------------- ------/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move02.dbf ONLINE SQL> !ls -l /u01/app/oracle/oradata/ORCL/datafile/ total 1590356 -rw-r-----. 1 oracle oinstall 744497152 Nov 3 11:19 o1_mf_sysaux_b53spns0_.dbf -rw-r-----. 1 oracle oinstall 807411712 Nov 3 11:20 o1_mf_system_b53ss9xf_.dbf -rw-r-----. 1 oracle oinstall 62922752 Nov 3 11:07 o1_mf_temp_b53swdsp_.tmp -rw-r-----. 1 oracle oinstall 57679872 Nov 3 11:20 o1_mf_undotbs1_b53svd7h_.dbf -rw-r-----. 1 oracle oinstall 5251072 Nov 3 10:04 o1_mf_users_b53svc3r_.dbf -rw-r-----. 1 oracle oinstall 10493952 Nov 3 11:22 tbs_file_to_move02.dbf SQL> alter database move datafile '/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move02.dbf' to '/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move01.dbf' keep; Database altered. SQL> select name,status from v$datafile where name like '%file_to_move%'; NAME STATUS ---------------------------------------------------------------------- ---------------------------------/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move01.dbf ONLINE SQL> !ls -l /u01/app/oracle/oradata/ORCL/datafile/ total 1600620 -rw-r-----. 1 oracle oinstall 744497152 Nov 3 11:24 o1_mf_sysaux_b53spns0_.dbf -rw-r-----. 1 oracle oinstall 807411712 Nov 3 11:24 o1_mf_system_b53ss9xf_.dbf -rw-r-----. 1 oracle oinstall 62922752 Nov 3 11:07 o1_mf_temp_b53swdsp_.tmp -rw-r-----. 1 oracle oinstall 57679872 Nov 3 11:24 o1_mf_undotbs1_b53svd7h_.dbf -rw-r-----. 1 oracle oinstall 5251072 Nov 3 10:04 o1_mf_users_b53svc3r_.dbf -rw-r-----. 1 oracle oinstall 10493952 Nov 3 11:24 tbs_file_to_move01.dbf -rw-r-----. 1 oracle oinstall 10493952 Nov 3 11:24 tbs_file_to_move02.dbf SQL> alter database move datafile '/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move01.dbf' to '/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move02.dbf' reuse; Database altered.
Online Datafile Movement
Page 3 of 5
SQL> select name,status from v$datafile where name like '%file_to_move%';
NAME STATUS ---------------------------------------------------------------------- -------------------------------------/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move02.dbf ONLINE SQL> !ls -l /u01/app/oracle/oradata/ORCL/datafile/ total 1590356 -rw-r-----. 1 oracle oinstall 744497152 Nov 3 11:25 o1_mf_sysaux_b53spns0_.dbf -rw-r-----. 1 oracle oinstall 807411712 Nov 3 11:30 o1_mf_system_b53ss9xf_.dbf -rw-r-----. 1 oracle oinstall 62922752 Nov 3 11:07 o1_mf_temp_b53swdsp_.tmp -rw-r-----. 1 oracle oinstall 57679872 Nov 3 11:30 o1_mf_undotbs1_b53svd7h_.dbf -rw-r-----. 1 oracle oinstall 5251072 Nov 3 10:04 o1_mf_users_b53svc3r_.dbf -rw-r-----. 1 oracle oinstall 10493952 Nov 3 11:32 tbs_file_to_move02.dbf SQL> select file# from v$datafile where name ='/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move02.dbf'; FILE# ---------2 SQL> alter database move datafile 2 to '/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move01.dbf'; Database altered. SQL> select name,status from v$datafile where name like '%file_to_move%'; NAME STATUS --------------------------------------------------------------------------------------------------- ------/u01/app/oracle/oradata/ORCL/datafile/tbs_file_to_move01.dbf ONLINE SQL> !ls -l /u01/app/oracle/oradata/ORCL/datafile/ total 1590356 -rw-r-----. 1 oracle oinstall 744497152 Nov 3 11:35 o1_mf_sysaux_b53spns0_.dbf -rw-r-----. 1 oracle oinstall 807411712 Nov 3 11:35 o1_mf_system_b53ss9xf_.dbf -rw-r-----. 1 oracle oinstall 62922752 Nov 3 11:07 o1_mf_temp_b53swdsp_.tmp -rw-r-----. 1 oracle oinstall 57679872 Nov 3 11:35 o1_mf_undotbs1_b53svd7h_.dbf -rw-r-----. 1 oracle oinstall 5251072 Nov 3 10:04 o1_mf_users_b53svc3r_.dbf -rw-r-----. 1 oracle oinstall 10493952 Nov 3 11:37 tbs_file_to_move01.dbf