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.

CHAPTER 13 ■ PARTITIONING 577<br />

We would have to remove the DEFAULT partition, then add PART_4, <strong>and</strong> then put the<br />

DEFAULT partition back. The reason behind this is that the DEFAULT partition could have had<br />

rows with the list partition key value of CA or NM—they would not belong in the DEFAULT partition<br />

after adding PART_4.<br />

Composite Partitioning<br />

Lastly, we’ll look at some examples of composite partitioning, which is a mixture of range <strong>and</strong><br />

hash or range <strong>and</strong> list.<br />

In composite partitioning, the top-level partitioning scheme is always range partitioning.<br />

The secondary level of partitioning is either list or hash (in <strong>Oracle</strong>9i Release 1 <strong>and</strong> earlier only<br />

hash subpartitioning is supported, not list). It is interesting to note that when you use composite<br />

partitioning, there will be no partition segments—there will be only subpartition<br />

segments. When using composite partitioning, the partitions themselves do not have segments<br />

(much like a partitioned table doesn’t have a segment). The data is physically stored in<br />

subpartition segments <strong>and</strong> the partition becomes a logical container, or a container that<br />

points to the actual subpartitions.<br />

In our example, we’ll look at a range-hash composite. Here we are using a different set of<br />

columns for the range partition from those used for the hash partition. This is not m<strong>and</strong>atory;<br />

we could use the same set of columns for both:<br />

ops$tkyte@ORA10G> CREATE TABLE composite_example<br />

2 ( range_key_column date,<br />

3 hash_key_column int,<br />

4 data varchar2(20)<br />

5 )<br />

6 PARTITION BY RANGE (range_key_column)<br />

7 subpartition by hash(hash_key_column) subpartitions 2<br />

8 (<br />

9 PARTITION part_1<br />

10 VALUES LESS THAN(to_date('01/01/2005','dd/mm/yyyy'))<br />

11 (subpartition part_1_sub_1,<br />

12 subpartition part_1_sub_2<br />

13 ),<br />

14 PARTITION part_2<br />

15 VALUES LESS THAN(to_date('01/01/2006','dd/mm/yyyy'))<br />

16 (subpartition part_2_sub_1,<br />

17 subpartition part_2_sub_2<br />

18 )<br />

19 )<br />

20 /<br />

Table created.<br />

In range-hash composite partitioning, <strong>Oracle</strong> will first apply the range partitioning rules<br />

to figure out which range the data falls into. Then it will apply the hash function to decide<br />

into which physical partition the data should finally be placed. This process is described in<br />

Figure 13-4.

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

Saved successfully!

Ooh no, something went wrong!