USING PARTITION
=============== ====
PARTITION BY RANGE-as per Oracle 8
--------------------------------------
[code=oracle]
CREATE TABLE RANGEPART
(
ID NUMBER(2) PRIMARY KEY,
NAME VARCHAR2(20)
)
PARTITION BY RANGE(ID)
(
PARTITION P1 VALUES LESS THAN(10),
PARTITION P2 VALUES LESS THAN(20),
PARTITION P3 VALUES LESS THAN(MAXVALUE)
);
[/code]
here in the sample code it creates a table with there parttions
1st value <10
2nd value 10-19
3rd 20 onwards
SAPMLE CODE FOR CREATING PARTITON BY HASH-as per 8i
=============== =============== =============== ===
[code=oracle]
CREATE TABLE HASHPART
(
ID NUMBER(10) PRIMARY KEY,
NAME VARCHAR2(20)
)
PARTITION BY HASH(NAME)
PARTITIONS 5;
[/code]
In this case user can't specify the name of partitions only number .
In this case it creates 5 partitions.
SAMPLE CODE FOR CREATING PARTITIONS BY LIST-as per 9i
=============== =============== =============== ===
[code=oracle]
CREATE TABLE LISTPART
(
ID NUMBER(10) PRIMARY KEY,
NAME VARCHAR2(20)
)
PARTITION BY LIST(NAME)
(
PARTITION P1 VALUES ('A','B'),
PARTITION P2 VALUES ('C','D'),
PARTITION P3 VALUES ('E','F')
);
[/code]
this type of partitons is mainly used for character datatypes.
Also check Using Partition - 2
=============== ====
PARTITION BY RANGE-as per Oracle 8
--------------------------------------
[code=oracle]
CREATE TABLE RANGEPART
(
ID NUMBER(2) PRIMARY KEY,
NAME VARCHAR2(20)
)
PARTITION BY RANGE(ID)
(
PARTITION P1 VALUES LESS THAN(10),
PARTITION P2 VALUES LESS THAN(20),
PARTITION P3 VALUES LESS THAN(MAXVALUE)
);
[/code]
here in the sample code it creates a table with there parttions
1st value <10
2nd value 10-19
3rd 20 onwards
SAPMLE CODE FOR CREATING PARTITON BY HASH-as per 8i
=============== =============== =============== ===
[code=oracle]
CREATE TABLE HASHPART
(
ID NUMBER(10) PRIMARY KEY,
NAME VARCHAR2(20)
)
PARTITION BY HASH(NAME)
PARTITIONS 5;
[/code]
In this case user can't specify the name of partitions only number .
In this case it creates 5 partitions.
SAMPLE CODE FOR CREATING PARTITIONS BY LIST-as per 9i
=============== =============== =============== ===
[code=oracle]
CREATE TABLE LISTPART
(
ID NUMBER(10) PRIMARY KEY,
NAME VARCHAR2(20)
)
PARTITION BY LIST(NAME)
(
PARTITION P1 VALUES ('A','B'),
PARTITION P2 VALUES ('C','D'),
PARTITION P3 VALUES ('E','F')
);
[/code]
this type of partitons is mainly used for character datatypes.
Also check Using Partition - 2