Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005
CHAPTER 13 ■ PARTITIONING 579 14 PARTITION part_2 15 VALUES LESS THAN(to_date('01/01/2006','dd/mm/yyyy')) 16 (subpartition part_2_sub_1 values ( 1, 3 ), 17 subpartition part_2_sub_2 values ( 5, 7 ), 18 subpartition part_2_sub_3 values ( 2, 4, 6, 8 ) 19 ) 20 ) 21 / Table created. Here you end up with five partitions altogether: two subpartitions for partition PART_1 and three for partition PART_2. Row Movement You might wonder what would happen if the column used to determine the partition is modified in any of the preceding partitioning schemes. There are two cases to consider: • The modification would not cause a different partition to be used; the row would still belong in this partition. This is supported in all cases. • The modification would cause the row to move across partitions. This is supported if row movement is enabled for the table; otherwise, an error will be raised. We can observe these behaviors easily. In the previous example, we inserted a pair of rows into PART_1 of the RANGE_EXAMPLE table: ops$tkyte@ORA10G> insert into range_example 2 ( range_key_column, data ) 3 values 4 ( to_date( '15-dec-2004 00:00:00', 5 'dd-mon-yyyy hh24:mi:ss' ), 6 'application data...' ); 1 row created. ops$tkyte@ORA10G> insert into range_example 2 ( range_key_column, data ) 3 values 4 ( to_date( '01-jan-2005 00:00:00', 5 'dd-mon-yyyy hh24:mi:ss' )-1/24/60/60, 6 'application data...' ); 1 row created. ops$tkyte@ORA10G> select * from range_example partition(part_1); RANGE_KEY DATA --------- -------------------- 15-DEC-04 application data... 31-DEC-04 application data...
580 CHAPTER 13 ■ PARTITIONING We take one of the rows and update the value in its RANGE_KEY_COLUMN such that it can remain in PART_1: ops$tkyte@ORA10G> update range_example 2 set range_key_column = trunc(range_key_column) 3 where range_key_column = 4 to_date( '31-dec-2004 23:59:59', 5 'dd-mon-yyyy hh24:mi:ss' ); 1 row updated. As expected, this succeeds: the row remains in partition PART_1. Next, we update the RANGE_KEY_COLUMN to a value that would cause it to belong in PART_2: ops$tkyte@ORA10G> update range_example 2 set range_key_column = to_date('02-jan-2005','dd-mon-yyyy') 3 where range_key_column = to_date('31-dec-2004','dd-mon-yyyy'); update range_example * ERROR at line 1: ORA-14402: updating partition key column would cause a partition change That immediately raises an error, since we did not explicitly enable row movement. In Oracle8i and later releases, we can enable row movement on this table to allow the row to move from partition to partition. ■Note The row movement functionality is not available on Oracle 8.0; you must delete the row and reinsert it in that release. You should be aware of a subtle side effect of doing this, however; namely that the ROWID of a row will change as the result of the update: ops$tkyte@ORA10G> select rowid 2 from range_example 3 where range_key_column = to_date('31-dec-2004','dd-mon-yyyy'); ROWID ------------------ AAARmfAAKAAAI+aAAB ops$tkyte@ORA10G> alter table range_example 2 enable row movement; Table altered. ops$tkyte@ORA10G> update range_example 2 set range_key_column = to_date('02-jan-2005','dd-mon-yyyy') 3 where range_key_column = to_date('31-dec-2004','dd-mon-yyyy'); 1 row updated.
- Page 574 and 575: CHAPTER 12 ■ DATATYPES 529 DT2-DT
- Page 576 and 577: CHAPTER 12 ■ DATATYPES 531 DT TS
- Page 578 and 579: CHAPTER 12 ■ DATATYPES 533 ops$tk
- Page 580 and 581: CHAPTER 12 ■ DATATYPES 535 Since
- Page 582 and 583: CHAPTER 12 ■ DATATYPES 537 ops$tk
- Page 584 and 585: CHAPTER 12 ■ DATATYPES 539 ops$tk
- Page 586 and 587: CHAPTER 12 ■ DATATYPES 541 suppor
- Page 588 and 589: CHAPTER 12 ■ DATATYPES 543 Concep
- Page 590 and 591: CHAPTER 12 ■ DATATYPES 545 We can
- Page 592 and 593: CHAPTER 12 ■ DATATYPES 547 buffer
- Page 594 and 595: CHAPTER 12 ■ DATATYPES 549 Note t
- Page 596 and 597: CHAPTER 12 ■ DATATYPES 551 13 dbm
- Page 598 and 599: CHAPTER 12 ■ DATATYPES 553 equall
- Page 600 and 601: CHAPTER 12 ■ DATATYPES 555 ROWID/
- Page 602 and 603: CHAPTER 13 ■ ■ ■ Partitioning
- Page 604 and 605: CHAPTER 13 ■ PARTITIONING 559 6 (
- Page 606 and 607: CHAPTER 13 ■ PARTITIONING 561 els
- Page 608 and 609: CHAPTER 13 ■ PARTITIONING 563 BIG
- Page 610 and 611: CHAPTER 13 ■ PARTITIONING 565 Enh
- Page 612 and 613: CHAPTER 13 ■ PARTITIONING 567 Tab
- Page 614 and 615: CHAPTER 13 ■ PARTITIONING 569 tha
- Page 616 and 617: CHAPTER 13 ■ PARTITIONING 571 PAR
- Page 618 and 619: CHAPTER 13 ■ PARTITIONING 573 35
- Page 620 and 621: CHAPTER 13 ■ PARTITIONING 575 If
- Page 622 and 623: CHAPTER 13 ■ PARTITIONING 577 We
- Page 626 and 627: CHAPTER 13 ■ PARTITIONING 581 ops
- Page 628 and 629: CHAPTER 13 ■ PARTITIONING 583 In
- Page 630 and 631: CHAPTER 13 ■ PARTITIONING 585 ops
- Page 632 and 633: CHAPTER 13 ■ PARTITIONING 587 | S
- Page 634 and 635: CHAPTER 13 ■ PARTITIONING 589 12
- Page 636 and 637: CHAPTER 13 ■ PARTITIONING 591 ops
- Page 638 and 639: CHAPTER 13 ■ PARTITIONING 593 •
- Page 640 and 641: CHAPTER 13 ■ PARTITIONING 595 Now
- Page 642 and 643: CHAPTER 13 ■ PARTITIONING 597 the
- Page 644 and 645: CHAPTER 13 ■ PARTITIONING 599 imp
- Page 646 and 647: CHAPTER 13 ■ PARTITIONING 601 OLT
- Page 648 and 649: CHAPTER 13 ■ PARTITIONING 603 5 s
- Page 650 and 651: CHAPTER 13 ■ PARTITIONING 605 Sur
- Page 652 and 653: CHAPTER 13 ■ PARTITIONING 607 On
- Page 654 and 655: CHAPTER 13 ■ PARTITIONING 609 Row
- Page 656 and 657: CHAPTER 13 ■ PARTITIONING 611 So,
- Page 658 and 659: CHAPTER 13 ■ PARTITIONING 613 Aud
- Page 660 and 661: CHAPTER 14 ■ ■ ■ Parallel Exe
- Page 662 and 663: CHAPTER 14 ■ PARALLEL EXECUTION 6
- Page 664 and 665: CHAPTER 14 ■ PARALLEL EXECUTION 6
- Page 666 and 667: CHAPTER 14 ■ PARALLEL EXECUTION 6
- Page 668 and 669: CHAPTER 14 ■ PARALLEL EXECUTION 6
- Page 670 and 671: CHAPTER 14 ■ PARALLEL EXECUTION 6
- Page 672 and 673: CHAPTER 14 ■ PARALLEL EXECUTION 6
CHAPTER 13 ■ PARTITIONING 579<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 values ( 1, 3 ),<br />
17 subpartition part_2_sub_2 values ( 5, 7 ),<br />
18 subpartition part_2_sub_3 values ( 2, 4, 6, 8 )<br />
19 )<br />
20 )<br />
21 /<br />
Table created.<br />
Here you end up with five partitions altogether: two subpartitions for partition PART_1 <strong>and</strong><br />
three for partition PART_2.<br />
Row Movement<br />
You might wonder what would happen if the column used to determine the partition is modified<br />
in any of the preceding partitioning schemes. There are two cases to consider:<br />
• The modification would not cause a different partition to be used; the row would still<br />
belong in this partition. This is supported in all cases.<br />
• The modification would cause the row to move across partitions. This is supported if<br />
row movement is enabled for the table; otherwise, an error will be raised.<br />
We can observe these behaviors easily. In the previous example, we inserted a pair of rows<br />
into PART_1 of the RANGE_EXAMPLE table:<br />
ops$tkyte@ORA10G> insert into range_example<br />
2 ( range_key_column, data )<br />
3 values<br />
4 ( to_date( '15-dec-2004 00:00:00',<br />
5 'dd-mon-yyyy hh24:mi:ss' ),<br />
6 'application data...' );<br />
1 row created.<br />
ops$tkyte@ORA10G> insert into range_example<br />
2 ( range_key_column, data )<br />
3 values<br />
4 ( to_date( '01-jan-2005 00:00:00',<br />
5 'dd-mon-yyyy hh24:mi:ss' )-1/24/60/60,<br />
6 'application data...' );<br />
1 row created.<br />
ops$tkyte@ORA10G> select * from range_example partition(part_1);<br />
RANGE_KEY DATA<br />
--------- --------------------<br />
15-DEC-04 application data...<br />
31-DEC-04 application data...