>  기사  >  데이터 베이스  >  Oracle建分区表

Oracle建分区表

WBOY
WBOY원래의
2016-06-07 16:22:421155검색

1、按月创建分区 create table T_MHDP ( ID VARCHAR2(50) not null, FLT_AIRCODE VARCHAR2(4), FLT_NUMBER NUMBER(7), FLT_DATE DATE ) partition by range (FLT_DATE) ( partition PART201105 values less than (TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM

   1、按月创建分区

  create table T_MHDP

  (

  ID VARCHAR2(50) not null,

  FLT_AIRCODE VARCHAR2(4),

  FLT_NUMBER NUMBER(7),

  FLT_DATE DATE

  ) partition by range (FLT_DATE)

  (

  partition PART201105 values less than (TO_DATE(' 2011-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))

  tablespace TS_MHDP_1105

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

  initial 64K

  next 1M

  minextents 1

  maxextents unlimited

  ),

  partition PART201106 values less than (TO_DATE(' 2011-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))

  tablespace TS_MHDP_1106

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

  initial 64K

  next 1M

  minextents 1

  maxextents unlimited

  ),

  partition PART201107 values less than (TO_DATE(' 2011-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))

  tablespace TS_MHDP_1107

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

  initial 64K

  next 1M

  minextents 1

  maxextents unlimited

  ),

  partition PARTDEFAULT values less than (TO_DATE(' 9999-12-30 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))

  tablespace TS_MHDP

  pctfree 10

  initrans 1

  maxtrans 255

  storage

  (

  initial 64K

  next 1M

  minextents 1

  maxextents unlimited

  )

  );

  2、创建全局索引

  create index INDEX_MHDP_PK on T_MHDP(ID)

  tablespace TS_INDEX_MHDP

  pctfree 10

  initrans 2

  maxtrans 255

  storage

  (

  initial 64K

  next 1M

  minextents 1

  maxextents unlimited

  );

  3、创建本地索引

  CREATE INDEX INDEX_MHDP_PK ON T_MHDP(ID) LOCAL (

  PARTITION PART201105 TABLESPACE TS_MHDP_INDEX_1105,

  PARTITION PART201106 TABLESPACE TS_MHDP_INDEX_1106,

  PARTITION PART201107 TABLESPACE TS_MHDP_INDEX_1107,

  PARTITION PARTDEFAULT TABLESPACE TS_MHDP_INDEX

  );

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.