|
As a DBA, you can create new tablespaces, resize data files associated to the tablespaces, add files to tablespaces, set default segment storage settings, alter default segment storage settings, make tablespaces read-only or read-write, make tablespaces temporary or permanent, and drop tablespaces. Recall that the database architecture includes both the logical structure (tablespaces, segments, extents, and data blocks) and the physical structure (control files, online redo log files, and data files). The Oracle Server enables the DBA to maintain fine-grained control of disk space through the use of the logical structures.
Figure 10.1 shows the relationship between the different logical and physical storage structures in the Oracle database and instance. Note that there is a one-to-many relationship between the database and tablespaces, between tablespaces and extents, between extents and Oracle blocks, between tablespaces and data files, between Oracle blocks and OS blocks, and between data files and OS blocks. These relationships can extend even further because the data files can be spread across different file systems, disks, and disk groups. Figure 10.1. Logical and physical configuration of the database.
The following list provides some of the outstanding characteristics of tablespaces:
The following list provides some of the outstanding characteristics of data files:
The following list provides some of the outstanding characteristics of segments:
The following list provides some of the outstanding characteristics of extents:
The following list provides some of the outstanding characteristics of data blocks:
Now that we have looked at the logical structure of the database, including tablespaces, in the next section we will look at how to manage the status of tablespaces. Managing Tablespace StatusTablespaces can have several different statuses. In the following sections, we will discuss online status (also considered to be read/write), offline status, and read-only status. These statuses are used for different reasons and can be used on the same tablespace at different times. Offline or OnlineTablespaces typically need to be online so that the data in the tablespaces is available. There are often reasons that you want to take a tablespace offline. When a tablespace has an offline status, it is not available for data access. No SQL statements can reference objects contained in the tablespace, and anyone trying to access any objects in the offline tablespace receives an error. Several tablespaces can never have an offline status: SYSTEM tablespace, default temporary tablespace, and an undo tablespace with active undo segments. You might want to take a tablespace offline to make a portion of the database unavailable while allowing normal access to the remainder of the database. You might do this to take an offline backup, to recover a tablespace or one or more of its data files while the database remains open and operable, or to move a data file while allowing the rest of the database to be open. The following command takes the tablespace mydata offline: ALTER TABLESPACE mydata OFFLINE; You can specify several different parameters for the offline statement. Those parameters, and their meanings, can be found in the following list:
When the tablespace is taken offline, all of that tablespace's associated data files are also taken offline. To bring the tablespace and its data files back online, you would issue the following command: ALTER TABLESPACE mydata ONLINE; Whenever a tablespace goes offline or comes back online, an event is recorded in the data dictionary so that Oracle can remember that the tablespace is offline. An event is also recorded in the control file. If you shut down the database with a tablespace in offline state, it will remain offline, and when the database restarts (in the mount and open portions of the open), the offline tablespace is not checked. Read-OnlyNot only can a tablespace be online or offline, it can also be made to be read-only. Read-only tablespaces are made available to users with only read operations possible, although objects can be dropped from read-only tablespaces. Dropped objects are possible because the data dictionary is the only thing updated in the drop. For locally managed tablespaces, the segments connected to the dropped objects are made into temporary segments to prevent the bitmap from being updated. When the tablespace is made read-only, it is first placed into a transitionally read-only state. During this period, no more write operations are permitted, but any writes that had taken place can either be committed or rolled back. After the active transactions are committed or are rolled back, the tablespace is fully placed in read-only mode. Even more interesting, you can create a read-only tablespace on a drive with removable media. After you have altered the tablespace to read-only with the following command, you can move the data file to a Write Once Read Many (WORM) device (such as a CD or DVD): ALTER TABLESPACE mydata READ ONLY; Cp d:\mydatabase\mydb1\mydata01.dbf e:\dvddrive\mydata01.dbf ALTER TABLESPACE mydata RENAME DATAFILE 'e:\dvddrive\mydata01.dbf\; You can bring tablespaces that are read-only back into read-write status by means of another ALTER statement: ALTER TABLESPACE mydata READ WRITE; All data files connected to the read-only tablespace that you want to make read-write have to be online and available.
You now know the basic logical structure of a tablespace. The next section looks at the different kinds of tablespaces that follow those logical constructs. |
|