oracle10g分区表(一)

剑道第一仙 / 2023-08-16 / 原文

一、创建分区表

create table lj_test_part
(
   birthdate date,
   age number(18,2)
)
PARTITION BY list (birthdate) 
(partition part_t01 values (to_date('2018-01-01', 'yyyy-mm-dd')),
partition part_t02 values (to_date('2018-01-02', 'yyyy-mm-dd')),
partition part_t03 values (to_date('2018-01-03', 'yyyy-mm-dd')),
partition part_t04 values (to_date('2018-01-04', 'yyyy-mm-dd')),
partition part_t05 values (to_date('2018-01-05', 'yyyy-mm-dd')))
;
insert into lj_test_part
select to_date('20180101','yyyymmdd'),10 from dual t 
union all
select to_date('20180102','yyyymmdd'),10 from dual t 
union all
select to_date('20180103','yyyymmdd'),10 from dual t 
union all
select to_date('20180104','yyyymmdd'),10 from dual t 
union all
select to_date('20180105','yyyymmdd'),10 from dual t ;

二、查询分区表


select count(*) from lj_test_part partition(part_t02);

三、添加分区

alter table lj_test_part add partition part_t11 values (to_date('2018-01-06', 'yyyy-mm-dd'));

四、删除分区

alter table lj_test_part drop partition part_t01;