среда, 9 октября 2013 г.

Recovery using the SWITCH DATABASE TO COPY command

Recover database from copy

rm users*.dbf
rman target /
RMAN> shutdown abort
# Recover database from copy
RMAN> startup mount;
RMAN> switch database to copy;
RMAN> recover database;
RMAN> alter database open;
SQL> select name,status from v$datafile;

Recover tablespace from copy

rm users*.dbf
rman target /
# Recover tablespace from copy
RMAN> sql 'alter tablespace users offline immediate';
RMAN> switch tablespace users to copy;
RMAN> recover tablespace users;
RMAN> sql 'alter tablespace users online';
SQL> select file_name from dba_data_files where tablespace_name='USERS';
# Move datafile from /backup/$ORACLE_SID to /data/$ORACLE_SID directory
# while the Database is online
SQL> alter tablespace users offline;
# Move the file /db_backup/ptdb1/users02.dbf using operating system command
cp /backup/users02.dbf /data/users02.dbf
# Update the database data dictionary
SQL> alter database rename file '/backup/users02.dbf' to '/data/users02.dbf';
# Take tablespace USERS online:
SQL> alter tablespace users online;
# Delete file from old location using operating system command
rm /backup/users02.dbf