Name

SWITCH

Synopsis

This command is analogous to the SQL ALTER DATABASE RENAME file command. It specifies that a datafile copy is now the current datafile and must be run from within the RUN command.

Syntax

SWITCH 
{ DATAFILE datafileSpec 
  [ TO DATAFILECOPY { 'filename' | TAG [=] [']tag_name['] }] 
| DATAFILE ALL
};

Example

The following example copies the datafile for the USERS tablespace to a different location. After doing so, the SWITCH command modifies the control file to make the datafile copy the current datafile.

RMAN> sql "alter database datafile 
  ''/d02/oradata/brdstn/users_01.dbf'' offline";
RMAN> sql statement: alter database datafile 
2> ''/d02/oradata/brdstn/users_01.dbf'' offline
RMAN> run {
2> copy datafile '/d02/oradata/brdstn/users_01.dbf' 
3> to '/d03/oradata/brdstn/users_01.dbf';
4> switch datafile '/d02/oradata/brdstn/users_01.dbf' 
5> to datafilecopy '/d03/oradata/brdstn/users_01.dbf';
6> }

Starting copy at 10-JUL-01
allocated channel: ORA_DISK_1
channel ORA_DISK_1: copied datafile 6
output filename=/d03/oradata/brdstn/users_01.dbf recid=4 
  stamp=434740922
Finished copy at 10-JUL-01

datafile 6 switched to datafile copy
input datafilecopy recid=4 stamp=434740922 filename=/d03/
  oradata/brdstn/users_01.dbf

RMAN> recover datafile '/d03/oradata/brdstn/users_01.dbf';

Starting recover at 10-JUL-01
using channel ORA_DISK_1

starting media recovery
media recovery complete

Finished recover at 10-JUL-01

RMAN> sql "alter database datafile 
  ''/d03/oradata/brdstn/foo_01.dbf'' online"; ...

Get Oracle RMAN Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.