Oracle Build partition Table

Source: Internet
Author: User
Tags create index

1. Create partitions on a monthly basis

CREATE TABLE T_MHDP

(

ID VARCHAR2 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 Global Index

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 local Index

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

);

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.