Quick Search:
 
 The Oracle PL/SQL PARTITION Keyword      [Return To Index] Jump to:  

Term: PARTITION

Definition:
In Oracle PL/SQL, using a PARTITION is a way to split a large table into smaller segments ("partitions"). Each partition is known by its specific name and has its own characteristics such as its storage and index. Partitioning is done based on a 'Partitioning Key', which is a column or set of columns from the same table whose consolidated value decide the partition for a given data. An index on a partition is known as Local Index, while an index which applies to a full table is known as a Global Index.

The primary objective of Oracle partitioning is to achieve better performance by excluding large volumes of data from query searches. A query to a partitioned table queries only the specific partition instead of scanning the full table. In addition, partitioning provides data archiving options based on range, dates, list and other parameters.

Listed below are the Partitioning methods available in Oracle PL/SQL.

  1. Interval Partitioning: Partitioning based on only one column of NUMBER or DATE type to specify Range, Hash and List. Interval Partitioning is not supported for Index Organized tables
  2. System Partitioning: Partitioning based on data movement into the tablespace(s)
  3. Composite Partitioning: Partitioning based on column(s) to specify range, hash or list
  4. Virtual Column Based Partitioning: Partitions based on Virtual Column value of the table
  5. Reference Partitioning: Partitioning based on Referential integrity. Reference Partitioning equi-partitions two tables based on a foreign key.

For more code samples and syntax examples, please view the page on Oracle Partitions

Example Usage:

The table T_WAREHOUSE captures the warehouse details from different locations. The LOC_CODE attribute is used to split the table with respect to the country codes. This demonstrates List Partitioning.

CREATE TABLE T_WAREHOUSE
(
ID NUMBER,
LOC_CODE VARCHAR2(50 BYTE),
SUPP_CODE NUMBER,
MATERIAL_CODE VARCHAR2(100 BYTE),
DESCRIPTION VARCHAR2(4000 BYTE),
)
PARTITION BY LIST (LOC_CODE)
(
PARTITION GRABB VALUES ('IND'),
PARTITION CNILX VALUES ('NZ'),
PARTITION NOAAS VALUES ('SL'),
PARTITION SGIND VALUES ('RSA'),
PARTITION SAARA VALUES ('PAK'),
PARTITION MYABB VALUES ('USA')
)


This example shows creating a Referential Partitioned table , where different values are stored in different tablespaces according to their value.

CREATE TABLE ref_parent (
table_name VARCHAR2(30),
order_date DATE,
num_rows NUMBER)
PARTITION BY RANGE(num_rows) (
PARTITION num_rows1 VALUES LESS THAN (100) TABLESPACE part1,
PARTITION num_rows2 VALUES LESS THAN (1000) TABLESPACE part2,
PARTITION num_rows3 VALUES LESS THAN (10000) TABLESPACE part3,
PARTITION num_rows4 VALUES LESS THAN (MAXVALUE) TABLESPACE part4);



Related Links:

Related Code Snippets:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org