Database Reference
In-Depth Information
Tablespace USER_DATA
/do1/user_data01.db1
T2
T2
T2
T2
T1
T1
T1
T1
T1
T1
T1
I1
I1
I1
I1
/do1/user_data02.dbf
Figure 3-3. A tablespace containing two data files, three segments, and four extents
Figure 3-3 shows a tablespace named USER_DATA . It consists of two data files, user_data01.dbf and user_
data02.dbf . It has three segments allocated to it: T1 , T2 , and I1 (probably two tables and an index). The tablespace
has four extents allocated in it, and each extent is depicted as a logically contiguous set of database blocks. Segment
T1 consists of two extents, one extent in each file. Segments T2 and I1 each have one extent depicted. If we need more
space in this tablespace, we could either resize the data files already allocated to the tablespace or we could add a
third data file to it.
A tablespace is a logical storage container in Oracle. As developers, we will create segments in tablespaces. We
will never get down to the raw file level—we don't specify that we want our extents to be allocated in a specific file
(we can, but in general we don't). Rather, we create objects in tablespaces and Oracle takes care of the rest. If at some
point in the future, the DBA decides to move our data files around on disk to more evenly distribute I/O, that is OK
with us. It will not affect our processing at all.
Storage Hierarchy Summary
In summary, the hierarchy of storage in Oracle is as follows:
1.
A database is made up of one or more tablespaces.
2.
A tablespace is made up of one or more data files. These files might be cooked files in a file
system, raw partitions, ASM managed database files, or a file on a clustered file system.
A tablespace contains segments.
3.
A segment ( TABLE , INDEX , and so on) is made up of one or more extents. A segment exists in
a tablespace, but may have data in many data files within that tablespace.
4.
An extent is a logically contiguous set of blocks on disk. An extent is in a single tablespace
and, furthermore, is always in a single file within that tablespace.
5.
A block is the smallest unit of allocation in the database. A block is the smallest unit of I/O
used by a database on data files.
Dictionary-Managed and Locally-Managed Tablespaces
Before we move on, let's look at one more topic related to tablespaces: how extents are managed in a tablespace. Prior
to Oracle 8.1.5, there was only one method for managing the allocation of extents within a tablespace: a dictionary-
managed tablespace. That is, the space within a tablespace was managed in data dictionary tables, in much the same
way you'd manage accounting data, perhaps with a DEBIT and CREDIT table. On the debit side, we have all of the extents
allocated to objects. On the credit side, we have all of the free extents available for use. When an object needed another
extent, it would ask the system for one. Oracle would then go to its data dictionary tables, run some queries, find the
space (or not), and then update a row in one table (or remove it all together) and insert a row into another. Oracle
managed space in very much the same way you write your applications: by modifying data and moving it around.
 
Search WWH ::




Custom Search