05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

340<br />

CHAPTER 10 ■ DATABASE TABLES<br />

• Table partition or subpartition: This segment type is used in partitioning <strong>and</strong> is very<br />

similar to a table segment. A table partition or subpartition segment holds just a slice of<br />

the data from a table. A partitioned table is made up of one or more table partition segments,<br />

<strong>and</strong> a composite partitioned table is made up of one or more table subpartition<br />

segments.<br />

• Index: This segment type holds an index structure.<br />

• Index partition: Similar to a table partition, this segment type contains some slice of an<br />

index. A partitioned index consists of one or more index partition segments.<br />

• Lob partition, lob subpartition, lobindex, <strong>and</strong> lobsegment: The lobindex <strong>and</strong> lobsegment<br />

segments hold the structure of a large object, or LOB. When a table containing a LOB is<br />

partitioned, the lobsegment will be partitioned as well—the lob partition segment is<br />

used for that. It is interesting to note that there is not a lobindex partition segment type—<br />

for whatever reason, <strong>Oracle</strong> marks the partitioned lobindex as an index partition (one<br />

wonders why a lobindex is given a special name!).<br />

• Nested table: This is the segment type assigned to nested tables, a special kind of “child”<br />

table in a master/detail relationship that we’ll discuss later.<br />

• Rollback <strong>and</strong> Type2 undo: This is where undo data is stored. Rollback segments are<br />

those manually created by the DBA. Type2 undo segments are automatically created<br />

<strong>and</strong> managed by <strong>Oracle</strong>.<br />

So, for example, a table may be a segment. An index may be a segment. I stress the words<br />

“may be” because we can partition an index into separate segments. So, the index object itself<br />

would just be a definition, not a physical segment—<strong>and</strong> the index would be made up of many<br />

index partitions, <strong>and</strong> each index partition would be a segment. A table may be a segment or<br />

not. For the same reason, we might have many table segments due to partitioning, or we might<br />

create a table in a segment called a cluster. Here the table will reside, perhaps with other tables<br />

in the same cluster segment.<br />

The most common case, however, is that a table will be a segment <strong>and</strong> an index will be a<br />

segment. That is the easiest way to think of it for now. When you create a table, you are normally<br />

creating a new table segment <strong>and</strong>, as discussed in Chapter 3, that segment consists of<br />

extents, <strong>and</strong> extents consist of blocks. That is the normal storage hierarchy. But it is important<br />

to note that only the “common” case has this one-to-one relationship. For example, consider<br />

this simple CREATE TABLE statement:<br />

Create table t ( x int primary key, y clob, z blob );<br />

This statement creates six segments. If you issue this CREATE TABLE statement in a schema<br />

that owns nothing, you’ll observe the following:<br />

ops$tkyte@ORA10G> select segment_name, segment_type<br />

2 from user_segments;<br />

no rows selected<br />

ops$tkyte@ORA10G> create table t ( x int primary key, y clob, z blob );<br />

Table created.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!