Oracle DBA : Altering Tablespaces Availability
Altering tablespace availability:
You can take an online tablespace offline so that it is temporarily unavailable for general use. The rest of the database remains open and available for users to access data. Conversely, you can bring an offline tablespace online to make the schema objects within the tablespace available to database users. The database must be open to alter the availability of a tablespace.
To alter the availability of a tablespace, use the alter tablespace statement. You must have the alter tablespace or manage tablespace system privilege.
Taking tablespaces offline:
You may want to take a tablespace offline for any of the following reasons:
- To make a portion of the database unavailable while allowing normal access to the remainder of the database
- To perform an offline tablespace backup (even though a tablespace can be backed up while online and in use)
- To make an application and its group of tables temporarily unavailable while updating or maintaining the application
- To rename or relocate tablespace datafiles
When a tablespace is taken offline, the database takes all the associated files offline.
You cannot take the following tablespaces offline:
- The undo tablespace
- Temporary tablespaces
Before taking a tablespace offline, consider altering the tablespace allocation of any users who have been assigned the tablespace as a default tablespace. Doing so is advisable because those users will not be able to access objects in the tablespace while it is offline.
You can specify any of the following parameters as part of the alter tablespace…offline statement:
A tablespace can be taken offline normally if no error conditions exist for any of the datafiles of the tablespace. No datafile in the tablespace can be currently offline as the result of a write error. When you specify offline normal, the database takes a checkpoint for all datafiles of the tablespace as it takes them offline. Normal is the default.
A tablespace can be taken offline temporarily, even if there are error conditions for one or more files of the tablespace. When you specify offline temporary, the database takes offline the datafiles that are not already offline, checkpointing them as it does so.
If no files are offline, but you use the temporary clause, media recovery is not required to bring the tablespace back online. However, if one or more files of the tablespace are offline because of write errors, and you take the tablespace offline temporarily, the tablespace requires recovery before you can bring it back online.
A tablespace can be taken offline immediately, without the database taking a checkpoint on any of the datafiles. When you specify offline immediate, media recovery for the tablespace is required before the tablespace can be brought online. You cannot take a tablespace offline immediately if the database is running in noarchivelog mode.
If you must take a tablespace offline, use the normal clause (the default) if possible. This setting guarantees that the tablespace will not require recovery to come back online, even if after incomplete recovery you reset the redo log sequence using an alter database open resetlogs statement.
Specify temporary only when you cannot take the tablespace offline normally. In this case, only the files taken offline because errors need to be recovered before the tablespace can be brought online. Specify immediate only after trying both the normal and temporary settings.
The following example takes the users tablespace offline normally:
Sql>alter tablespace users offline normal;
Bringing tablespaces online:
You can bring any tablespace in an oracle database online whenever the database is open. A tablespace is normally online so that the data contained within it is available to database users.
If a tablespace to be brought online was not taken offline “cleanly” (that is, using the normal clause of the alter tablespace offline statement), you must first perform media recovery on the tablespace before bringing it online. Otherwise, the database returns an error and the tablespace remains offline.
The following statement brings the users tablespace online:
Sql>alter tablespace users online;