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

Recovery using the SWITCH DATABASE TO COPY command

Recover database from copy

  1. rm users*.dbf
  2. rman target /
  3. RMAN> shutdown abort
  4. # Recover database from copy
  5. RMAN> startup mount;
  6. RMAN> switch database to copy;
  7. RMAN> recover database;
  8. RMAN> alter database open;
  9. SQL> select name,status from v$datafile;

Recover tablespace from copy

  1. rm users*.dbf
  2. rman target /
  3. # Recover tablespace from copy
  4. RMAN> sql 'alter tablespace users offline immediate';
  5. RMAN> switch tablespace users to copy;
  6. RMAN> recover tablespace users;
  7. RMAN> sql 'alter tablespace users online';
  8. SQL> select file_name from dba_data_files where tablespace_name='USERS';
  9. NAME
  10. ----------------------------
  11. /data/users01.dbf
  12. /backup/users02.dbf
  13. # Move datafile from /backup/$ORACLE_SID to /data/$ORACLE_SID directory
  14. # while the Database is online
  15. SQL> alter tablespace users offline;
  16. # Move the file /db_backup/ptdb1/users02.dbf using operating system command
  17. cp /backup/users02.dbf /data/users02.dbf
  18. # Update the database data dictionary
  19. SQL> alter database rename file '/backup/users02.dbf' to '/data/users02.dbf';
  20. # Take tablespace USERS online:
  21. SQL> alter tablespace users online;
  22. # Delete file from old location using operating system command
  23. rm /backup/users02.dbf