分区表创建

--范围分区
-- Create table
create table SALES2
(
  SALE_NO   CHAR(10) not null,
  SALE_DATE CHAR(8) not null,
  SALE_NUM  NUMBER(38) not null,
  SALE_TYPE CHAR(1) not null,
  OUT_DATE  CHAR(8),
  CUSTOM    VARCHAR2(30)
)
partition by range (SALE_DATE)
(
  partition PART1 values less than ('20010101'),
  partition PART3 values less than ('20030101'),
  partition PART4 values less than ('20040101'),
  partition PART5 values less than ('20050101'),
  partition PART6 values less than ('20060101'),
  partition PART7 values less than ('20070101'),
  partition PART8 values less than ('20080101'),
  partition PART9 values less than ('20090101'),
  partition PART10 values less than ('20100101'),
  partition PART2 values less than ('20110101')
)
;
-- Create/Recreate primary, unique and foreign key constraints
alter table SALES2
  add constraint PK_SALES2 primary key (SALE_NO);
--列表分区
-- create table
create table people
(
  pid      char(10),
  pname    varchar2(30) not null,
  sex      char(1),
  birthday char(8),
  areano   varchar2(10)
)
partition by list (areano)
(
  partition part2 values ('河北'),
  partition part3 values ('山东'),
  partition part5 values ('湖南'),
  partition part6 values ('湖北'),
  partition part7 values ('江苏'),
  partition part8 values ('浙江'),
  partition part9 values ('云南', '西藏'),
  partition part10 values ('贵州', '内蒙古', '黑龙江', '辽宁'),
  partition part0 values (default)
)
;
-- create/recreate indexes
create index ind_people_name on people (pname);

猜你喜欢

转载自jeelee.iteye.com/blog/1402029