You are on page 1of 3

What are the different types of indexes in Oracle? Please give examples for all indexes.

There are several types of indexes available in Oracle all designed for different circumstances: b*tree indexes - the most common type (especially in OLTP environments) and the default type b*tree cluster indexes - for clusters hash cluster indexes - for hash clusters reverse ey indexes - useful in Oracle !eal "pplication #luster (!"#) applications bitmap indexes - common in data$arehouse applications partitioned indexes - also useful for data$arehouse applications function-based indexes index organised tables domain indexes Let%s loo at these Oracle index types in a little more detail&

B*Tree Indexes
'*tree stands for balanced tree& This means that the height of the index is the same for all values thereby ensuring that retrieving the data for any one value ta es approximately the same amount of time as for any other value& Oracle b*tree indexes are best used $hen each value has a high cardinality (lo$ number of occurrences)for example primary ey indexes or uni(ue indexes& One important point to note is that )*LL values are not indexed& They are the most common type of index in OLTP systems&

B*Tree Cluster Indexes


These are '*tree index defined for clusters& #lusters are t$o or more tables $ith one or more common columns and are usually accessed together (via a +oin)& CREATE I !E" prod#ct$orders$ix O C%&'TER prod#ct$orders(

Hash Cluster Indexes


,n a hash cluster ro$s that have the same hash ey value (generated by a hash function) are stored together in the Oracle database& -ash clusters are e(uivalent to indexed clusters. except the index ey is replaced $ith a hash function& This also means that here is no separate index as the hash is the index& CREATE C%&'TER emp$dept$cl#ster )dept$id &*+ER, -A'-.E/' 01(

Reverse Key Indexes

These are typically used in Oracle !eal "pplication #luster (!"#) applications& ,n this type of index the bytes of each of the indexed columns are reversed (but the column order is maintained)& This is useful $hen ne$ data is al$ays inserted at one end of the index as occurs $hen using a se(uence as it ensures ne$ index values are created evenly across the leaf bloc s preventing the index from becoming unbalanced $hich may in turn affect performance& CREATE I !E" emp$ix O emp)emp$id, RE2ER'E(

Bitmap Indexes
These are commonly used in data$arehouse applications for tables $ith no updates and $hose columns have lo$ cardinality (i&e& there are fe$ distinct values)& ,n this type of index Oracle stores a bitmap for each distinct value in the index $ith / bit for each ro$ in the table& These bitmaps are expensive to maintain and are therefore not suitable for applications $hich ma e a lot of $rites to the data& 0or example consider a car manufacturer $hich records information about cars sold including the colour of each car& 1ach colour is li ely to occur many times and is therefore suitable for a bitmap index& CREATE +IT*AP I !E" car$col O cars)colo#r, RE2ER'E(

Partitioned Indexes
Partitioned ,ndexes are also useful in Oracle data$arehouse applications $here there is a large amount of data that is partitioned by a particular dimension such as time& Partition indexes can either be created as local partitioned indexes or global partitioned indexes& Local partitioned indexes means that the index is partitioned on the same columns and $ith the same number of partitions as the table& 0or global partitioned indexes the partitioning is user defined and is not the same as the underlying table& !efer to the create index statement in the Oracle 23L language reference for details&

Function-based Indexes
"s the name suggests these are indexes created on the result of a function modifying a column value& 0or example CREATE I !E" #pp$ename O emp)&PPER)ename,,(

The function must be deterministic (al$ays return the same value for the same inputs)&

Index

r!anised Tables

,n an index-organised table all the data is stored in teh Oracle database in a '*tree index structure defined on the table%s primary ey& This is ideal $hen related pieces of data must be stored together or data must be physically stored in a specific order& ,ndex-organised tables are often used for information retrieval. spatial and OL"P applications&

"omain Indexes
These indexes are created by user-defined indexing routines and enable the user to define his or her o$n indexes on custom data types (domains) such as pictures. maps or fingerprints for example& These type of index re(uire in-depth no$ledge about the data and ho$ it $ill be accessed& Loo ing for more help $ith Oracle4 5ith our partners. $e offer instructor-led training in the *6 and in the *2 as $ell as classroom-(uality online training& 2ee our Oracle training page for more details&

You might also like