3.5. Recovering Read-Only Tablespaces

A read-only tablespace is a tablespace that contains static information. This means that in most cases, no media recovery is required. This type of read-only tablespace recovery is of a non-critical nature.

There are only a few times when media recovery is required with a read-only tablespace. The first is when the last backup of the read-only tablespace was taken when the tablespace was read-write and the tablespace was made read-only afterward. The second is when the tablespace was read-only when the last backup was taken, then was made read-write in between, and then was made read-only again. These two scenarios are really saying that the checkpoint process that updates the SCNs for the control file and file headers will need to be synchronized by the recovery process of applying log files. These two methods are the same as any other tablespace recovery. Read-only recovery is described in Table 3.1.

Because the most common method of read-only tablespace recovery is that no media recovery is needed, we will walk through an example of this approach. This is non-critical recovery method. Let's look at recovering a read-only tablespace in this manner.

Table 3.1. Read-Only Tablespace Recovery Scenarios
Read-Only Recovery TypeDescriptionStatus
Read-only to read-onlyBackup was taken read-only; no changes were made to the tablespace, and it was recovered to read-only.Non-critical recovery.
Read-write to read-onlyBackup was taken read-write, and the tablespace was recovered to read-only.Critical recovery requires redo logs and the RECOVER command.
Read-only to read-write to read-onlyBackup was taken read-only; the tablespace was modified read-write, and then recovered to read-only.Critical recovery requires redo logs and the RECOVER command.

  1. First, make the tablespace USERS read-only and force this statement to archive log by switching through the redo logs:

    SQL> alter tablespace users read only;
    
    Tablespace altered.
    
    SQL> alter system switch logfile;
    
    System altered.
    
    SQL> alter system switch logfile;
    
    System altered.
    
    SQL> alter system switch logfile;
    
    System altered.
    
    SQL> alter system switch logfile;
    
    System altered.

  2. We are using a Windows environment for our example. If we were using Unix, the command is cp to copy the file. Next, shut down the database ORA101T and make a cold backup in the C:oracleoradataackupora101t directory for restore purposes:

    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    
    SQL> host
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    
    C:Documents and Settingsdstuns> cd c:oracleoradataackupora101t
    
    c:oracleoradataackupora101t> copy c:oracleoradataora101t*

  3. Again, we are using a Windows environment for our example. If we were using Unix, the command is rm to delete the file. Simulate a missing or lost USERS tablespace by deleting users01.dbf:

    C:oracleoradataackupora101t> cd ....ora101t
    
    C:oracleoradataora101t> delete users01.dbf

  4. Start up the database to see the error:

    SQL> startup
    ORACLE instance started.
    
    Total System Global Area      88080384 bytes
    Fixed Size                      787588 bytes
    Variable Size                 78642044 bytes
    Database Buffers               8388608 bytes
    Redo Buffers                    262144 bytes
    Database mounted.
    ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
    ORA-01110: data file 4: 'C:ORACLEORADATAORA101TUSERS01.DBF'

  5. Shut down the database and do a restore of the users01.dbf read-only tablespaces datafile:

    SQL> shutdown immediate
    ORA-01109: database not open
    
    Database dismounted.

    ORACLE instance shut down.
    
    SQL> host
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    
    C:Documents and Settingsdstuns> cd c:oracleoradataora101t
    C:oracleoradataora101t> copy c:oracleoradataackupora101tusers01.dbf
    
    users01.dbf C:oracleoradataora101t> exit

  6. Finally, start the database ORA101T without issue because the user01.dbf has been restored:

    SQL> startup
    ORACLE instance started.
    
    Total System Global Area  88080384 bytes
    Fixed Size                  787588 bytes
    Variable Size             78642044 bytes
    Database Buffers           8388608 bytes
    Redo Buffers                262144 bytes
    Database mounted. Database opened.
    SQL>

As you can see, the USERS01.DBF datafile for the read-only tablespaces only needs to be restored. No recovery is required because there are no changes in the datafile. Essentially this means that the USERS01.DBF datafile's header does not change when database checkpointing updates SCN values in the normal read-write datafiles. So the USERS tablespace is static after it becomes read-only.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset