分割槽表中的maxvalue引數設定

還不算暈發表於2013-10-27
結論:partition p3 values less than (maxvalue)   分割槽表中maxvalue如果用具體引數來代替,則整個表中可插入的最大值不能超過指定的引數。
如指定引數是15,則插入的值只能是小於15.
partition p1 values less than (5)  這裡的引數5,意味著插入此分割槽的數值要小於5,不能大於等於。

實驗1:使用maxvalue


SQL> create table test1(ab number) partition by range(ab) (partition p1 values less than (5) tablespace users,partition p2 values less than (10) tablespace users2,partition p3 values less than (maxvalue) tablespace users3);
 
Table created
SQL> insert into test1 select rownum from dual connect by rownum<13;
 
12 rows inserted


實驗二:使用指定引數,插入資料驗證整個表中可插入的最大值不能超過指定的引數的結論。


SQL> create table test5(ab number) partition by range(ab) (partition p1 values less than (4) tablespace users,partition p2 values less than (8) tablespace users2,partition p3 values less than (15) tablespace users3);
Table created
SQL> select * from test5;
        AB
----------
 
SQL> select * from test5 partition(p1);
        AB
----------
 
SQL> insert into test5 select rownum from dual connect by rownum<17;
insert into test5 select rownum from dual connect by rownum<17
ORA-14400: inserted partition key does not map to any partition
 
SQL> insert into test5 select rownum from dual connect by rownum<16;
insert into test5 select rownum from dual connect by rownum<16
ORA-14400: inserted partition key does not map to any partition
 
SQL> insert into test5 select rownum from dual connect by rownum<15;
14 rows inserted
SQL> commit;
Commit complete
 
SQL> select * from test5 partition(p1);
        AB
----------
         1
         2
         3
SQL> select * from test5 partition(p2);
        AB
----------
         4
         5
         6
         7
SQL> select * from test5 partition(p3);
        AB
----------
         8
         9
        10
        11
        12
        13
        14 
SQL> select * from test5 ;
        AB
----------
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
14 rows selected

相關文章