每天自动创建分区表的问题
正常我们创建表时,使用UPDATA_TIME为分区字段,并且该字段为DATE类型,每天自动创建分区表,按以下脚本成功创建
create table t_day
( seqnumber not null,
update_timedate,
constraint t_day_seq primary key(seq)
)
partition by range(update_time)
interval(numtodsinterval(1,'day'))
( partition t_day1 values less than(to_date('20170101','yyyymmdd')) tablespace users);
现有生产需要,update_time 必须为char类型,该如何实现每天按update_time创建分区表?
create table t_day
( seqnumber not null,
update_timechar(8),
constraint t_day_seq primary key(seq)
)
partition by range(to_date(update_time,'yyyymmdd')) --这样执行出现错误 ORA--00907缺失右括号
interval(numtodsinterval(1,'day'))
( partition t_day1 values less than(to_date('20170101','yyyymmdd')) tablespace users);
用虚拟列+range分区就行。需要向原来的表加一列虚拟列:
create table t_day
( seqnumber not null,
update_timechar(8),
constraint t_day_seq primary key(seq),
col1date as ( to_date('20170101','yyyymmdd') )
)
partition by range( col1 )
interval(numtodsinterval(1,'day'))
( partition t_day1 values less than(to_date('20170101','yyyymmdd')) tablespace users); botang 发表于 2017-11-21 15:44
用虚拟列+range分区就行。需要向原来的表加一列虚拟列:
{:3_41:}谢谢老师。。。 botang 发表于 2017-11-21 15:44
用虚拟列+range分区就行。需要向原来的表加一列虚拟列:
嗯,谢谢老师。。。
页:
[1]