0% found this document useful (0 votes)
26 views4 pages

Partition Types

The document outlines various types of table partitioning methods including Range, List, Hash, and Composite Partitioning, each with specific use cases and examples. It also discusses Index Partitioning, distinguishing between Local and Global Partition Indexes, and provides examples for both. Additionally, it covers the maintenance of Global Partition Indexes and the creation of Partition Index Organized tables.

Uploaded by

shalih786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

Partition Types

The document outlines various types of table partitioning methods including Range, List, Hash, and Composite Partitioning, each with specific use cases and examples. It also discusses Index Partitioning, distinguishing between Local and Global Partition Indexes, and provides examples for both. Additionally, it covers the maintenance of Global Partition Indexes and the creation of Partition Index Organized tables.

Uploaded by

shalih786
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Types Partition of Table:

------------------------

1. Range Partition.
2. List Partition.
3. Hash Partition.
4. Sub Partition (Composite Partition).

Range Partition:
----------------

 Range partitioning maps data to partitions based on ranges of partition key


values that you
establish for each partition.

 It is the most common type of partitioning and is often used with dates.

Example:
--------

CREATE TABLE sales_range(salesman_id NUMBER(5),


salesman_name VARCHAR2(30),
sales_amount NUMBER(10),
sales_date DATE)
PARTITION BY RANGE(sales_date)
(
PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY')),
PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY')),
PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','DD/MM/YYYY')),
PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY'))
);

List Partition:
---------------

 List partitioning enables you to explicitly control how rows map to partitions.

 You do this by specifying a list of discrete values for the partitioning key in
the description for
each partition.

Example:
-------

CREATE TABLE sales_list(salesman_id NUMBER(5),


salesman_name VARCHAR2(30),
sales_state VARCHAR2(20),
sales_amount NUMBER(10),
sales_date DATE)
PARTITION BY LIST(sales_state)
(PARTITION sales_west VALUES('California', 'Hawaii') COMPRESS,
PARTITION sales_east VALUES('New York', 'Virginia', 'Florida'),
PARTITION sales_central VALUES('Texas', 'Illinois'));

Hash Partition:
--------------
 Hash partitioning enables easy partitioning of data that does not lend itself to
range or list
partitioning. It does this with a simple syntax and is easy to implement.

 It is a better choice than range partitioning when


o You do not know beforehand how much data maps into a given range
o The sizes of range partitions would differ quite substantially or would be
difficultto
balance manually
o Range partitioning would cause the data to be undesirably clustered.
o In Store In class must be contain power of 2 Partition.

Example:
-------

CREATE TABLE sales_hash (salesman_id NUMBER(5),


salesman_name VARCHAR2(30),
sales_amount NUMBER(10),
week_no NUMBER(2))
PARTITION BY HASH(salesman_id)
PARTITIONS 4;

Composite Partition:
--------------------

 Composite partitioning partitions data using the range method, and within each
partition,
sub-partitions it using the hash or list method.

 Composite range-hash partitioning provides the improved manageability of range


partitioning
and the data placement, striping, and parallelism advantages of hash
partitioning.

 Composite range-list partitioning provides the manageability of range


partitioning and the
explicit control of list partitioning for the sub-partitions.

Composite Range-Hash Example:


----------------------------
CREATE TABLE sales_composite(salesman_id NUMBER(5),
salesman_name VARCHAR2(30),
sales_amount NUMBER(10),
sales_date DATE)
PARTITION BY RANGE(sales_date)
SUBPARTITION BY HASH(salesman_id)
SUBPARTITION TEMPLATE(
SUBPARTITION sp1 TABLESPACE data1,
SUBPARTITION sp2 TABLESPACE data2,
SUBPARTITION sp3 TABLESPACE data3,
SUBPARTITION sp4 TABLESPACE data4)
(PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY'))
PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY'))
PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','DD/MM/YYYY'))
PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY'))
PARTITION sales_may2000 VALUES LESS THAN(TO_DATE('06/01/2000','DD/MM/YYYY')));
Composite Range-List Example:
----------------------------

CREATE TABLE bimonthly_regional_sales(deptno NUMBER,


item_no VARCHAR2(20),
txn_date DATE,
txn_amount NUMBER,
state VARCHAR2(2))
PARTITION BY RANGE (txn_date)
SUBPARTITION BY LIST (state)
SUBPARTITION TEMPLATE(
SUBPARTITION east VALUES('NY', 'VA', 'FL') TABLESPACE ts1,
SUBPARTITION west VALUES('CA', 'OR', 'HI') TABLESPACE ts2,
SUBPARTITION central VALUES('IL', 'TX', 'MO') TABLESPACE ts3);

Index Partition:
----------------

 Just like partitioned tables, partitioned indexes improve manageability,


availability,
performance, and scalability.

 They can either be partitioned independently (global indexes)

 or automatically linked to a table's partitioning method (local indexes).

Local Partition Index:


----------------------
 The reason for this is equi-partitioning: each partition of a local index is
associated with exactly
one partition of the table.

 This enables Oracle to automatically keep the index partitions in sync with the
table partitions,
and makes each table-index pair independent.

 Any actions that make one partition's data invalid or unavailable only affect a
single partition.

 You cannot explicitly add a partition to a local index. Instead, new partitions
are added to local
indexes only when you add a partition to the underlying table.

 Likewise, you cannot explicitly drop a partition from a local index. Instead,
local index partitions
are dropped only when you drop a partition from the underlying table.

Example:
--------
CREATE INDEX invoices_idx ON invoices (invoice_date) LOCAL
(PARTITION invoices_q1 TABLESPACE users,
PARTITION invoices_q2 TABLESPACE users,
PARTITION invoices_q3 TABLESPACE users,
PARTITION invoices_q4 TABLESPACE users);

Global Partition Index:


-----------------------

 Global partitioned indexes are flexible in that the degree of partitioning and
the partitioningkey
are independent from the table's partitioning method.

 They are commonly used for OLTP environments and offer efficient access to
anyindividual
record.

Example:
--------

CREATE INDEX employees_global_part_idx ON employees(employee_id)


GLOBAL PARTITION BY RANGE(employee_id)
(PARTITION p1 VALUES LESS THAN(5000),
PARTITION p2 VALUES LESS THAN(MAXVALUE));

Maintenance of Global Partition Index:


-------------------------------------

ADD (HASH)
COALESCE (HASH)
DROP
EXCHANGE
MERGE
MOVE
SPLIT
TRUNCATE

Partition Index Organized table Creation:


----------------------------------------

CREATE TABLE sales_range


(
salesman_id NUMBER(5),
salesman_name VARCHAR2(30),
sales_amount NUMBER(10),
sales_date DATE,
PRIMARY KEY(sales_date, salesman_id))
ORGANIZATION INDEX INCLUDING salesman_id
OVERFLOW TABLESPACE tabsp_overflow
PARTITION BY RANGE(sales_date)
(PARTITION sales_jan2000 VALUES LESS THAN(TO_DATE('02/01/2000','DD/MM/YYYY'))
OVERFLOW TABLESPACE p1_overflow,
PARTITION sales_feb2000 VALUES LESS THAN(TO_DATE('03/01/2000','DD/MM/YYYY'))
OVERFLOW TABLESPACE p2_overflow,
PARTITION sales_mar2000 VALUES LESS THAN(TO_DATE('04/01/2000','DD/MM/YYYY'))
OVERFLOW TABLESPACE p3_overflow,
PARTITION sales_apr2000 VALUES LESS THAN(TO_DATE('05/01/2000','DD/MM/YYYY'))
OVERFLOW TABLESPACE p4_overflow);

You might also like