如果这样看,似乎有些不太合理了,是什么原因导致这些数据进入p120_c10了呢。
来做个简单的测试模拟一下,发现对于这个多键值的分区表,分区的情况和单键值还是有很大的差别,比较容易混淆和误导。当第一个键值的条件满足时,就忽略了第二个键值的条件,(比如(55,70),55已经小于第一个键值了,就直接插入p120_c10了,忽略了后面的一个条件)
如果键值等于120的时候,就开始校验第二个条件了(比如(120,5), (120,15)都校验了后面的键值,数据分别进入了p120_c10,p120_c20这两个分区)
如果键值大于120的时候,如果没有默认的分区,就直接报错了,因为Oracle根据这种匹配还找不到对应的分区。
create table test (period_key number,customer_key number)
partition by range(period_key,customer_key)
(
partition p120_c10 values less than (120,10),
partition p120_c20 values less than (120,20),
partition p120_c30 values less than (120,30)
);
SQL> insert into test values(57,99);
1 row created.
SQL> insert into test values(57,150);
1 row created.
SQL> insert into test values(120,5);
1 row created.
SQL> insert into test values(119,50);
1 row created.
SQL> insert into test values(120,5);
1 row created.
SQL> insert into test values(120,15);
1 row created.
SQL> insert into test values(120,25);
1 row created.
SQL> insert into test values(120,30);
insert into test values(120,30)
*
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
SQL> insert into test values(121,1);
insert into test values(121,1)
*
ERROR at line 1:
ORA-14400: inserted partition key does not map to any partition
SQL> select *from test partition(p120_c10);
PERIOD_KEY CUSTOMER_KEY
---------- ------------
57 99
57 150
120 5
119 50
120 5
SQL> select *from test partition(p120_c20);
PERIOD_KEY CUSTOMER_KEY
---------- ------------
120 15
SQL> select *from test partition(p120_c30);
PERIOD_KEY CUSTOMER_KEY
---------- ------------
120 25
对于这个问题,只能根据业务的角度进行重新规划来把数据进一步balance了。