创建分区表
create table TABLENAME
(
proposalno varchar2(22),
startdate date
)
partition by range(STARTDATE)
interval(numtoyminterval(1,'MONTH'))(
partition part_t01 values less than(to_date('2008-01-01','yyyy-mm-dd')) ,
partition part_t02 values less than(to_date('2009-01-01','yyyy-mm-dd')) ,
partition part_t03 values less than(to_date('2010-01-01','yyyy-mm-dd')) ,
partition part_t04 values less than(to_date('2011-01-01','yyyy-mm-dd')) ,
partition part_t05 values less than(to_date('2012-01-01','yyyy-mm-dd')) ,
partition part_t06 values less than(to_date('2013-01-01','yyyy-mm-dd'))
);
(
proposalno varchar2(22),
startdate date
)
partition by range(STARTDATE)
interval(numtoyminterval(1,'MONTH'))(
partition part_t01 values less than(to_date('2008-01-01','yyyy-mm-dd')) ,
partition part_t02 values less than(to_date('2009-01-01','yyyy-mm-dd')) ,
partition part_t03 values less than(to_date('2010-01-01','yyyy-mm-dd')) ,
partition part_t04 values less than(to_date('2011-01-01','yyyy-mm-dd')) ,
partition part_t05 values less than(to_date('2012-01-01','yyyy-mm-dd')) ,
partition part_t06 values less than(to_date('2013-01-01','yyyy-mm-dd'))
);
--STARTDATE表示以这个字段分区,其类型必须是date类型,比如后装的项目以GPSTIME分区,把STARTDATE换成GPSTIME就行
--查询分区的数据行
SELECT COUNT(*) FROM 用户.tablename PARTITION(分区名);