将数据插入到间隔分区表时,为什么无法创建分区

时间:2018-07-20 07:26:59

标签: oracle partitioning

当我按范围间隔创建分区表并按照SQL所示手动创建第一个分区时。

  CREATE TABLE "HDEVAMP"."POS_DATA" 
   (    "START_DATE" DATE, 
    "STORE_ID" NUMBER, 
    "INVENTORY_ID" NUMBER(6,0), 
    "QTY_SOLD" NUMBER(3,0)
   ) 
  PARTITION BY RANGE ("START_DATE") INTERVAL (NUMTOYMINTERVAL(1, 'MONTH')) 
 (PARTITION "POS_DATA_P27"  VALUES LESS THAN (TO_DATE('2018-02-01','yyyy-mm-dd')));

为什么当我插入分区键为20171231的数据时未自动创建分区。

     insert into pos_data values (TO_DATE('2017-12-31','YYYY-MM-DD'),1,110,12);
insert into pos_data values (TO_DATE('2018-01-31','YYYY-MM-DD'),1,110,12);
commit;

它仅创建一个分区POS_DATA_P27来存储以上两个数据,而不创建一个分区来存储“ 2017-12-31”的数据

"TABLE_NAME","COMPOSITE","PARTITION_NAME","SUBPARTITION_COUNT","HIGH_VALUE","HIGH_VALUE_LENGTH","PARTITION_POSITION","TABLESPACE_NAME","PCT_FREE","PCT_USED","INI_TRANS","MAX_TRANS","INITIAL_EXTENT","NEXT_EXTENT","MIN_EXTENT","MAX_EXTENT","MAX_SIZE","PCT_INCREASE","FREELISTS","FREELIST_GROUPS","LOGGING","COMPRESSION","COMPRESS_FOR","NUM_ROWS","BLOCKS","EMPTY_BLOCKS","AVG_SPACE","CHAIN_CNT","AVG_ROW_LEN","SAMPLE_SIZE","LAST_ANALYZED","BUFFER_POOL","FLASH_CACHE","CELL_FLASH_CACHE","GLOBAL_STATS","USER_STATS","IS_NESTED","PARENT_TABLE_PARTITION","INTERVAL","SEGMENT_CREATED","INDEXING","INMEMORY","INMEMORY_PRIORITY","INMEMORY_DISTRIBUTE","INMEMORY_COMPRESSION","INMEMORY_DUPLICATE"
"POS_DATA","NO","POS_DATA_P27",0,"TO_DATE(' 2018-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')",83,1,"SYSTEM",10,40,1,255,65536,1048576,1,2147483645,2147483645,,1,1,"YES","DISABLED","",,,,,,,,,"DEFAULT","DEFAULT","DEFAULT","NO","NO","NO","","NO","YES","ON","DISABLED","","","",""

1 个答案:

答案 0 :(得分:1)

您创建了一个分区LESS THAN 2018-02-01 00:00:00,这意味着:2018年2月1日之前的所有内容都将进入该分区。

20171231,即2017-12-31显然早于2018-02-01,那么您期望什么?

Oracle将在2018年2月1日之后为 值创建新分区。