3

我想每天自动对我的表 (Oracle) 进行分区。

我只有一个 Timestamp 列:

 DD.MM.YYYY HH24:MI:SS

到目前为止,我发现了这个,但它不起作用:

create table 
pos_data ( 
    start_date        DATE,
    store_id          NUMBER,
    inventory_id      NUMBER(6),
    qty_sold          NUMBER(3),
 ) 
 PARTITION BY RANGE (start_date) 
 INTERVAL(NUMTOYMINTERVAL(1, 'MONTH')) 
 (  
  PARTITION pos_data_p2 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')),
  PARTITION pos_data_p3 VALUES LESS THAN (TO_DATE('1-8-2007', 'DD-MM-YYYY')) 
 ); 

在这个例子中,我得到了 Invalid Identifier 错误......而且我不知道时间戳是否对日期列有影响。

回答:

create table 
pos_data_two ( 
    start_date        TIMESTAMP,
    store_id          NUMBER,
    inventory_id      NUMBER(6),
    qty_sold          NUMBER(3)
 ) 
 PARTITION BY RANGE (start_date) 
 INTERVAL(NUMTODSINTERVAL (1, 'DAY')) 
 (  
  PARTITION pos_data_p2 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')),
  PARTITION pos_data_p3 VALUES LESS THAN (TO_DATE('1-8-2007', 'DD-MM-YYYY')) 
 ); 
4

2 回答 2

3

那是因为你错误地放了一个,afterqty_sold NUMBER(3),删除它然后这样尝试,

create table 
pos_data ( 
    start_date        DATE,
    store_id          NUMBER,
    inventory_id      NUMBER(6),
    qty_sold          NUMBER(3)
 ) 
 PARTITION BY RANGE (start_date) 
 INTERVAL(NUMTOYMINTERVAL(1, 'MONTH')) 
 (  
  PARTITION pos_data_p2 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')),
  PARTITION pos_data_p3 VALUES LESS THAN (TO_DATE('1-8-2007', 'DD-MM-YYYY')) 
 ); 
于 2013-10-30T08:30:24.700 回答
1

您有一个逗号对多个(在qty_sold列定义之后):

create table 
pos_data ( 
    start_date        DATE,
    store_id          NUMBER,
    inventory_id      NUMBER(6),
    qty_sold          NUMBER(3)
 ) 
 PARTITION BY RANGE (start_date) 
 INTERVAL(NUMTOYMINTERVAL(1, 'MONTH')) 
 (  
  PARTITION pos_data_p2 VALUES LESS THAN (TO_DATE('1-7-2007', 'DD-MM-YYYY')),
  PARTITION pos_data_p3 VALUES LESS THAN (TO_DATE('1-8-2007', 'DD-MM-YYYY')) 
 );
于 2013-10-30T08:30:32.343 回答