脚踏实地、勇往直前!
全部博文(1005)
分类: Oracle
2012-04-01 16:06:50
2.写入数据
insert into tb_hxl_no_part_t values(date'2010-01-01',1);
insert into tb_hxl_no_part_t values(date'2010-02-01',1);
insert into tb_hxl_no_part_t values(date'2010-03-01',1);
insert into tb_hxl_no_part_t values(date'2010-04-01',1);
insert into tb_hxl_no_part_t values(date'2010-05-01',1);
insert into tb_hxl_no_part_t values(date'2010-06-01',1);
insert into tb_hxl_no_part_t values(date'2010-07-01',1);
insert into tb_hxl_no_part_t values(date'2010-08-01',1);
insert into tb_hxl_no_part_t values(date'2010-09-01',1);
insert into tb_hxl_no_part_t values(date'2010-10-01',1);
insert into tb_hxl_no_part_t values(date'2010-11-01',1);
insert into tb_hxl_no_part_t values(date'2010-12-01',1);
insert into tb_hxl_no_part_t values(date'2011-01-01',1);
insert into tb_hxl_no_part_t values(date'2011-02-01',1);
insert into tb_hxl_no_part_t values(date'2011-03-01',1);
insert into tb_hxl_no_part_t values(date'2011-04-01',1);
insert into tb_hxl_no_part_t values(date'2011-05-01',1);
insert into tb_hxl_no_part_t values(date'2011-06-01',1);
insert into tb_hxl_no_part_t values(date'2011-07-01',1);
insert into tb_hxl_no_part_t values(date'2011-08-01',1);
insert into tb_hxl_no_part_t values(date'2011-09-01',1);
insert into tb_hxl_no_part_t values(date'2011-10-01',1);
insert into tb_hxl_no_part_t values(date'2011-11-01',1);
insert into tb_hxl_no_part_t values(date'2011-12-01',1);
insert into tb_hxl_no_part_t values(date'2012-01-01',1);
insert into tb_hxl_no_part_t values(date'2012-02-01',1);
insert into tb_hxl_no_part_t values(date'2012-03-01',1);
insert into tb_hxl_no_part_t values(date'2012-04-01',1);
commit;
3.创建分区表(将2012-04-01以前的数据放入一个分区,用来备份)
create table tb_hxl_part_t
(
statedate date,
count number
)
partition by range (statedate)
(
partition p_20120401 values less than (to_date('2012-04-02','YYYY-MM-DD')),
partition p_20120402 values less than (to_date('2012-04-03','YYYY-MM-DD')),
partition p_20120403 values less than (to_date('2012-04-04','YYYY-MM-DD')),
partition p_20120404 values less than (to_date('2012-04-05','YYYY-MM-DD')),
partition p_20120405 values less than (to_date('2012-04-06','YYYY-MM-DD'))
);
4.交换分区
SQL>alter table tb_hxl_part_t exchange partition p_20120401 with table tb_hxl_no_part_t;