Suppose you submit the following ALTER TABLE request on orders:
ALTER TABLE orders MODIFY PRIMARY INDEX ADD RANGE BETWEEN 0 AND 4 EACH 2;This alters the partitioning expression to be:
RANGE_N(o_custkey BETWEEN 0 AND 4 EACH 2, 5 AND 9 EACH 1, 10 AND 100 EACH 10);
That is, the table definition after you have performed the ALTER TABLE request is as follows:
CREATE TABLE orders ( o_orderkey INTEGER NOT NULL, o_custkey INTEGER) PRIMARY INDEX (o_orderkey) PARTITION BY RANGE_N(o_custkey BETWEEN 0 AND 4 EACH 2, 5 AND 9 EACH 1, 10 AND 100 EACH 10);
This changes the information implied by the third table definition about the partitioning of orders as follows:
- Number of partitions in the first, and only, level = d1 = 18
- Total number of combined partitions = d1 = 18
- Combined partitioning expression = p1
Now if o_custkey is 15, the following additional information is implied.
- Partition number for level 1 = PARTITION#L1 = p1(15) = 9.
- PARTITION#L2 through PARTITION#L15 are all 0.
- Combined partition number = PARTITION = p1(15) = 9.
The following table indicates the new partition numbers for the defined ranges for o_custkey.
| Value of o_custkey | Result of the new RANGE_N function Value of PARTITION Value of PARTITION#L1 |
|---|---|
| 0 - 1 | 1 |
| 2 - 3 | 2 |
| 4 | 3 |
| 5 | 4 |
| 6 | 5 |
| 7 | 6 |
| 8 | 7 |
| 9 | 8 |
| 10 - 19 | 9 |
| 20 - 29 | 10 |
| 30 - 39 | 11 |
| 40 - 49 | 12 |
| 50 - 59 | 13 |
| 60 - 69 | 14 |
| 70 - 79 | 15 |
| 80 - 89 | 16 |
| 90 - 99 | 17 |
| 100 | 18 |