Here is the procedure for moving the datafiles from DISK to ASM. This procedure involves the use of RMAN onlyfor moving the file.

1.create the tablespace

SQL> create tablespace TEST_ASM datafile '/tmp/testasm.dbf' size 10M;

Tablespace created.

SQL> select file_name from dba_data_files where tablespace_name ='TEST_ASM';

FILE_NAME

------

/tmp/testasm.dbf

2. take the tablespace offline, you may take offline a single datafile from a multifiletablespace if required.

SQL> ALTER TABLESPACE TEST_ASM OFFLINE;

Tablespace altered.

3. Check where are your datafiles located on ASM

selectfile_name from dba_data_files;

FILE_NAME

------

+DATA/INTRAC03/DATAFILE/system.256.853285035

+DATA/INTRAC03/DATAFILE/sysaux.257.853285035

+DATA/INTRAC03/DATAFILE/tspitr_1.272.888140075

+DATA/INTRAC03/DATAFILE/users.260.853285035

+DATA/INTRAC03/DATAFILE/undotbs2.258.853285035

+DATA/INTRAC03/DATAFILE/undotbs1.259.853285035

/tmp/testasm.dbf

+DATA/INTRAC03/DATAFILE/test_asm2.274.919009571

8 rows selected.

4. Log out from sqlplus, start an RMAN session and execute the copy command

Note that when giving the destination inside ASM you just need to pass the disk group name when using omf (Oracle Managed Files) that is the best practice in ASM.

SQL> exit

Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Advanced Analytics and Real Application Testing options

[oracle@IND120201 ~]$ rman target /

Recovery Manager: Release 12.1.0.1.0 - Production on Thu Aug 4 15:41:55 2016

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.

connected to target database: INTRAC03 (DBID=2104245680)

RMAN> copydatafile '/tmp/testasm.dbf' to '+DATA';

Starting backup at 04-AUG-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=88 instance=INTRAC03_1 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=89 instance=INTRAC03_1 device type=DISK

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00007 name=/tmp/testasm.dbf

output file name=+DATA/INTRAC03/DATAFILE/test_asm.273.919011593 tag=TAG20160804T165953 RECID=3 STAMP=919011595

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03

Finished backup at 04-AUG-16

Starting Control File and SPFILE Autobackup at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-07 comment=NONE

Finished Control File and SPFILE Autobackup at 04-AUG-16

5.Now switch the datafile to the copy created.

RMAN> switch datafile '/tmp/testasm.dbf' to copy;

datafile 7 switched to datafile copy "+DATA/INTRAC03/DATAFILE/test_asm.273.919011593"

RMAN> alter tablespacetest_asm online;

Statement processed

RMAN>exit

IMP: If the tablespace/datafile is made offline after taking the copy of datafile and before switching from RMAN. Then after switch datafile we need to recover the tablespace/datafile.

SQL> select file_name from dba_data_files;

FILE_NAME

------

+DATA/INTRAC03/DATAFILE/system.256.853285035

+DATA/INTRAC03/DATAFILE/sysaux.257.853285035

+DATA/INTRAC03/DATAFILE/tspitr_1.272.888140075

+DATA/INTRAC03/DATAFILE/users.260.853285035

+DATA/INTRAC03/DATAFILE/undotbs2.258.853285035

+DATA/INTRAC03/DATAFILE/undotbs1.259.853285035

+DATA/INTRAC03/DATAFILE/test_asm.273.919011593

+DATA/INTRAC03/DATAFILE/test_asm2.274.919009571

8 rows selected.

SQL>

6. remove the old file

hostrm /tmp/testasm.dbf

[oracle@IND120201 ~]$ rman target /

Recovery Manager: Release 12.1.0.1.0 - Production on Thu Aug 4 17:06:00 2016

Copyright (c) 1982, 2013, Oracle and/or its affiliates. All rights reserved.

connected to target database: INTRAC03 (DBID=2104245680)

RMAN> report obsolete;

using target database control file instead of recovery catalog

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

Report of obsolete backups and copies

Type Key Completion Time Filename/Handle

------

Backup Set 28 04-AUG-16

Backup Piece 28 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-06

RMAN> backup database plus archivelog delete input;

Starting backup at 04-AUG-16

current log archived

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=89 instance=INTRAC03_1 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=88 instance=INTRAC03_1 device type=DISK

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=43 RECID=88 STAMP=919011989

channel ORA_DISK_1: starting piece 1 at 04-AUG-16

channel ORA_DISK_2: starting archived log backup set

channel ORA_DISK_2: specifying archived log(s) in backup set

input archived log thread=2 sequence=46 RECID=89 STAMP=919011992

channel ORA_DISK_2: starting piece 1 at 04-AUG-16

channel ORA_DISK_1: finished piece 1 at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s63_s1 tag=TAG20160804T170635 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=+FRA/INTRAC03/ARCHIVELOG/2016_08_04/thread_1_seq_43.486.919011989 RECID=88 STAMP=919011989

channel ORA_DISK_2: finished piece 1 at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s64_s1 tag=TAG20160804T170635 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02

channel ORA_DISK_2: deleting archived log(s)

archived log file name=+FRA/INTRAC03/ARCHIVELOG/2016_08_04/thread_2_seq_46.488.919011993 RECID=89 STAMP=919011992

Finished backup at 04-AUG-16

Starting backup at 04-AUG-16

using channel ORA_DISK_1

using channel ORA_DISK_2

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

inputdatafile file number=00001 name=+DATA/INTRAC03/DATAFILE/system.256.853285035

inputdatafile file number=00005 name=+DATA/INTRAC03/DATAFILE/tspitr_1.272.888140075

inputdatafile file number=00008 name=+DATA/INTRAC03/DATAFILE/test_asm2.274.919009571

inputdatafile file number=00006 name=+DATA/INTRAC03/DATAFILE/users.260.853285035

channel ORA_DISK_1: starting piece 1 at 04-AUG-16

channel ORA_DISK_2: starting full datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

inputdatafile file number=00003 name=+DATA/INTRAC03/DATAFILE/sysaux.257.853285035

inputdatafile file number=00002 name=+DATA/INTRAC03/DATAFILE/undotbs2.258.853285035

inputdatafile file number=00004 name=+DATA/INTRAC03/DATAFILE/undotbs1.259.853285035

inputdatafile file number=00007 name=+DATA/INTRAC03/DATAFILE/test_asm.273.919011593

channel ORA_DISK_2: starting piece 1 at 04-AUG-16

channel ORA_DISK_1: finished piece 1 at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011998_s65_s1 tag=TAG20160804T170638 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55

channel ORA_DISK_2: finished piece 1 at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011998_s66_s1 tag=TAG20160804T170638 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:02:15

Finished backup at 04-AUG-16

Starting backup at 04-AUG-16

current log archived

using channel ORA_DISK_1

using channel ORA_DISK_2

channel ORA_DISK_1: starting archived log backup set

channel ORA_DISK_1: specifying archived log(s) in backup set

input archived log thread=1 sequence=44 RECID=91 STAMP=919012137

channel ORA_DISK_1: starting piece 1 at 04-AUG-16

channel ORA_DISK_2: starting archived log backup set

channel ORA_DISK_2: specifying archived log(s) in backup set

input archived log thread=2 sequence=47 RECID=90 STAMP=919012136

channel ORA_DISK_2: starting piece 1 at 04-AUG-16

channel ORA_DISK_1: finished piece 1 at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919012140_s67_s1 tag=TAG20160804T170859 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: deleting archived log(s)

archived log file name=+FRA/INTRAC03/ARCHIVELOG/2016_08_04/thread_1_seq_44.486.919012137 RECID=91 STAMP=919012137

channel ORA_DISK_2: finished piece 1 at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919012140_s68_s1 tag=TAG20160804T170859 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02

channel ORA_DISK_2: deleting archived log(s)

archived log file name=+FRA/INTRAC03/ARCHIVELOG/2016_08_04/thread_2_seq_47.488.919012137 RECID=90 STAMP=919012136

Finished backup at 04-AUG-16

Starting Control File and SPFILE Autobackup at 04-AUG-16

piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-08 comment=NONE

Finished Control File and SPFILE Autobackup at 04-AUG-16

RMAN> report obsolete;

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

Report of obsolete backups and copies

Type Key Completion Time Filename/Handle

------

Backup Set 23 04-AUG-16

Backup Piece 23 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009670_s55_s1

Backup Set 24 04-AUG-16

Backup Piece 24 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009670_s56_s1

Backup Set 26 04-AUG-16

Backup Piece 26 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009867_s58_s1

Backup Set 27 04-AUG-16

Backup Piece 27 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009867_s59_s1

Backup Set 28 04-AUG-16

Backup Piece 28 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-06

Datafile Copy 4 04-AUG-16 /tmp/testasm.dbf

Backup Set 29 04-AUG-16

Backup Piece 29 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-07

Backup Set 31 04-AUG-16

Backup Piece 31 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s63_s1

Backup Set 30 04-AUG-16

Backup Piece 30 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s64_s1

RMAN> delete obsolete;

RMAN retention policy will be applied to the command

RMAN retention policy is set to redundancy 1

using channel ORA_DISK_1

using channel ORA_DISK_2

Deleting the following obsolete backups and copies:

Type Key Completion Time Filename/Handle

------

Backup Set 23 04-AUG-16

Backup Piece 23 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009670_s55_s1

Backup Set 24 04-AUG-16

Backup Piece 24 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009670_s56_s1

Backup Set 26 04-AUG-16

Backup Piece 26 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009867_s58_s1

Backup Set 27 04-AUG-16

Backup Piece 27 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009867_s59_s1

Backup Set 28 04-AUG-16

Backup Piece 28 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-06

Datafile Copy 4 04-AUG-16 /tmp/testasm.dbf

Backup Set 29 04-AUG-16

Backup Piece 29 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-07

Backup Set 31 04-AUG-16

Backup Piece 31 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s63_s1

Backup Set 30 04-AUG-16

Backup Piece 30 04-AUG-16 /mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s64_s1

Do you really want to delete the above objects (enter YES or NO)? yes

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009670_s55_s1 RECID=23 STAMP=919009671

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009670_s56_s1 RECID=24 STAMP=919009671

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009867_s58_s1 RECID=26 STAMP=919009867

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919009867_s59_s1 RECID=27 STAMP=919009867

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-06 RECID=28 STAMP=919009875

deleteddatafile copy

datafile copy file name=/tmp/testasm.dbf RECID=4 STAMP=919011712

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/c-2104245680-20160804-07 RECID=29 STAMP=919011601

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s63_s1 RECID=31 STAMP=919011995

deleted backup piece

backup piece handle=/mnt/hgfs/Shared_Folder/rman_backup/INTRAC03/ora_df919011995_s64_s1 RECID=30 STAMP=919011995

Deleted 9 objects

RMAN>

When we used SQLPLUS to rename the datafile in the precious document here, it raised the error while issue delete obsolete because the copy made by RMAN becomes the online datafile after renaming via SQLPLUS.

But here we used RMAN only, and switched the datafilecopy( on ASM ) with the file on the disk. Thus the file on the disk becomes the datafilecopy and removed by the command delete obsolete.