www.company.com
Partitioning
Presented By :
Reema Gajjar
www.company.com
What is partitioning?
When to partition a table?
Partitioning stratergies
Partitioning operations
Advantages of partitioning
Disadvantages of partitioning
What We'll Cover ...
www.company.com
What Is Partitioning ??
Partitioning allows tables, indexes to be subdivided into
smaller pieces.
Each piece of database object is called PARTITIONS.
Tables are partitioned using a 'PARTITION KEY', a set of
column/columns which determine in which partition a given row will
reside.
Company
LOGO
www.company.com
What Is Partitioning ??
Company
LOGO
www.company.com
When to Partition a table???
“Slow” queries ??
Tables containing historical data, in which new data is
added into newest partition.
When the contents of a table need to be distributed across
different types of storage devices.
Company
LOGO
www.company.com
Partitioning Strategies
Company
LOGO
1. Range partitioning
2. Interval partitioning
3. List partitioning
4. Hash partitioning
5. Composite partitioning
www.company.com
1. Range Partitioning
It maps data into partition based on ranges of partition key
values.
Partitioning done based on consecutive range of values.
Ex : Partition sales data into monthly partitions.
Company
LOGO
www.company.com
1. Range Partitioning
Company
LOGO
January to August data
www.company.com
Range Partitioning Example
sal_3
sal_more
sal_4
sal_3
sal_2
sal_more
sal_1
sal_1
Inserting A Records Into Range Partitioned Table :
www.company.com
2. Interval Partitioning
Extension of range partitioning.
Automatically create new partition when data inserted into
a table exceeds transition point.
TRANSITION POINT – highest range partition.
You must specify atleast one range partition.
Company
LOGO
www.company.com
Interval Partitioning Example
Inserting A Records Into Interval Partitioned Table :
sal_3
SYS_P14160
SYS_P14159
30000
40000
55000
High_value
www.company.com
Interval Partitioning Example
Company
LOGO
www.company.com
3. List Partitioning
Company
LOGO
Company
LOGO
Partitioning done based on list of discrete values for the
partition key .
Enables to group and organize unordered and unrelated
sets of data.
Ex : States into a Region
www.company.com
3. List Partitioning
Company
LOGO
Company
LOGO
Sales Data
www.company.com
List Partitioning Example
Company
LOGO
p1
p2
p3
p4
p3
p5
Inserting A Records Into List Partitioned Table :
www.company.com
4. Hash Partitioning
Company
LOGO
Hash partitioning stores data to partitions based on a
hashing algorithm that oracle applies to the partitioning
key.
Distribution is handled by oracle.
Ex : order table → partitioned by cust_id
Company
LOGO
www.company.com
4. Hash Partitioning
Company
LOGO
Company
LOGO
Order Table
www.company.com
Hash Partitioning Example
Company
LOGO
www.company.com
Hash Partitioning Example
Company
LOGO
www.company.com
View All Partitions Of Table
Company
LOGO
www.company.com
SELECTING RECORDS
Company
LOGO
Syntax :
select * from TABLE_NAME partition
(PARTITION_NAME);
www.company.com
Adding a Partition
Company
LOGO
1. ADDING PARTITIONS :
Syntax :
ALTER TABLE table_name ADD PARTITION
partition_name VALUES LESS THAN (VALUE);
Partitioning Operations
www.company.com
Adding a Partition
Company
LOGO
1. ADDING PARTITIONS :
Range :
We can't add partition when maxvalue specified in range
partition.
We can't add partition for the lower ranges.
List :
We can't add partition when default specified in list partition
method.
Interval :
We can't add partitions.
Partitioning Operations
www.company.com
Dropping a Partition
Company
LOGO
2. DROPING PARTITIONS :
Syntax :
ALTER TABLE table_name DROP PARTITION
partition_name ;
Hash :
We can't drop partitions created by hash method.
Partitioning Operations
www.company.com
Renaming a Partition
Company
LOGO
3. RENAMING PARTITIONS :
Syntax :
ALTER TABLE table_name RENAME PARTITION
old_partition_name TO new_partition_name;
Partitioning Operations
www.company.com
Splitting a Partition
Company
LOGO
4. SPLITTING PARTITIONS :
Syntax :
ALTER TABLE table_name SPLIT PARTITION
partition_name AT (value) INTO ( PARTITION
partition_name1 , PARTITION partition_name2);
Partitioning Operations
www.company.com
Splitting a Partition
Company
LOGO
4. SPLITTING PARTITIONS :
Hash :
We can't split partitions.
Partitioning Operations
www.company.com
Merging a Partition
Company
LOGO
5. MERGING PARTITIONS :
Syntax :
ALTER TABLE table_name MERGE PARTITION
partition_name1,partition_name2 INTO PARTITION
partition_name3;
Partitioning Operations
www.company.com
Merging a Partition
Company
LOGO
5. MERGING PARTITIONS :
Hash :
We can't merge partitions.
Partitioning Operations
www.company.com
Advantages Of Partitioning
Performance
Manageability
Availability
Company
LOGO
www.company.com
Disadvantage Of Partitioning
You need to buy licenses before you can use it.
It take up a space.
additional administration tasks to manage partitions.
Company
LOGO
www.company.com
Thank You...
Company
LOGO

Partitioning