Oracle Partitions by Fayyaz Ahmed
Oracle Partitions by Fayyaz Ahmed
All the examples shown here use the users tablespace for all partitions. In a real situation it
is likely that these partitions would be assigned to different tablespaces to reduce device
contention.
Or specified individually.
Partitioning Indexes
There are two basic types of partitioned index.
• Local - All index entries in a single partition will correspond to a single table
partition (equipartitioned). They are created with the LOCAL keyword and support
partition independance. Equipartioning allows oracle to be more efficient whilst
devising query plans.
• Global - Index in a single partition may correspond to multiple table partitions.
They are created with the GLOBAL keyword and do not support partition
independance. Global indexes can only be range partitioned and may be partitioned
Written by Fayyaz ahmed
in such a fashion that they look equipartitioned, but Oracle will not take advantage
of this structure.
Both types of indexes can be subdivided further.
• Prefixed - The partition key is the leftmost column(s) of the index. Probing this type
of index is less costly. If a query specifies the partition key in the where clause
partition pruning is possible, that is, not all partitions will be searched.
• Non-Prefixed - Does not support partition pruning, but is effective in accessing data
that spans multiple partitions. Often used for indexing a column that is not the
tables partition key, when you would like the index to be partitioned on the same
key as the underlying table.
Local Prefixed Indexes
Assuming the INVOICES table is range partitioned on INVOICE_DATE, the followning are
examples of local prefixed indexes.
Oracle will generate the partition names and build the partitions in the default tablespace
using the default size unless told otherwise.
Note that the partition range values must be specified. The GLOBAL keyword means that
Oracle can not assume the partition key is the same as the underlying table.
Next we create a new partitioned table with a single partition to act as our destination
table.
Written by Fayyaz ahmed
Next we switch the original table segment with the partition segment.
We can now drop the original table and rename the partitioned table.
Finally we can split the partitioned table into multiple partitions as required and gather
new statistics.
TABLE_NAME PARTITION_NAME
HIGH_VALUE NUM_ROWS
------------------------------ ------------------------------ --------
------------ ----------
Written by Fayyaz ahmed
MY_TABLE MY_TABLE_PART_1 3
2
MY_TABLE MY_TABLE_PART_2 MAXVALUE
2
2 rows selected.