05.11.2015 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

576<br />

CHAPTER 13 ■ PARTITIONING<br />

PART_1<br />

PART_2<br />

Figure 13-3. List partition insert example<br />

If you want to segregate these seven states into their separate partitions, as we have,<br />

but have all remaining state codes (or, in fact, any other row that happens to be inserted<br />

that doesn’t have one of these seven codes) go into a third partition, then we can use the<br />

VALUES ( DEFAULT ) clause. Here, we’ll alter the table to add this partition (we could use<br />

this in the CREATE TABLE statement as well):<br />

ops$tkyte@ORA10G> alter table list_example<br />

2 add partition<br />

3 part_3 values ( DEFAULT );<br />

Table altered.<br />

ops$tkyte@ORA10G> insert into list_example values ( 'VA', 'data' );<br />

1 row created.<br />

All values that are not explicitly in our list of values will go here. A word of caution on the<br />

use of DEFAULT: once a list partitioned table has a DEFAULT partition, you cannot add any more<br />

partitions to it:<br />

ops$tkyte@ORA10G> alter table list_example<br />

2 add partition<br />

3 part_4 values( 'CA', 'NM' );<br />

alter table list_example<br />

*<br />

ERROR at line 1:<br />

ORA-14323: cannot add partition when DEFAULT partition exists

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

Saved successfully!

Ooh no, something went wrong!