Connecting Tech Pros Worldwide Forums | Help | Site Map

Using Partition -1

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#1   May 19 '07
USING PARTITION
===================
PARTITION BY RANGE-as per Oracle 8
--------------------------------------
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE RANGEPART
  2. (
  3. ID NUMBER(2) PRIMARY KEY,
  4. NAME VARCHAR2(20)
  5. )
  6. PARTITION BY RANGE(ID)
  7. (
  8. PARTITION P1 VALUES LESS THAN(10),
  9. PARTITION P2 VALUES LESS THAN(20),
  10. PARTITION P3 VALUES LESS THAN(MAXVALUE)
  11. );
  12.  
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
================================================
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE HASHPART
  2. (
  3. ID NUMBER(10) PRIMARY KEY,
  4. NAME VARCHAR2(20)
  5. )
  6. PARTITION BY HASH(NAME)
  7. PARTITIONS 5;
  8.  
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
================================================
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE LISTPART
  2. (
  3. ID NUMBER(10) PRIMARY KEY,
  4. NAME VARCHAR2(20)
  5. )
  6. PARTITION BY LIST(NAME)
  7. (
  8. PARTITION P1 VALUES ('A','B'),
  9. PARTITION P2 VALUES ('C','D'),
  10. PARTITION P3 VALUES ('E','F')
  11. );
  12.  
this type of partitons is mainly used for character datatypes.



Also check Using Partition - 2

Last edited by debasisdas; Feb 8 '08 at 05:59 AM. Reason: some editing



Reply