You are on page 1of 12

1 Copyright 2014, Oracle and/or its affiliates. All rights reserved.

INDEXES
To speed up SQL statement execution on a table
Without an index, Oracle will do a full table search
Indexes are most useful on larger tables, on columns that are
likely to appear in where clauses as simple equality

2 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


DICTIONARY TABLES

ALL_INDEXES
DBA_INDEXES
USER_INDEXES
ALL_IND_COLUMNS
DBA_IND_COLUMNS
USER_IND_COLUMNS

3 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


TYPES

UNIQUE INDEX
NON-UNIQUE INDEX
COMPOSITE INDEX
FUNCTIONBASED INDEX
BTREE INDEX
BITMAP INDEX

4 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


UNIQUE INDEX

Unique indexes guarantee that no two rows of a table have


duplicate values in the columns that define the index.

automatically created when primary key or unique constraint


is created.

Ex:
create unique index idx_empno on emp(empno);

5 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


NON-UNIQUE INDEX

Non-Unique indexes do not impose the above (UNIQUE INDEX)


restriction on the column values.

Ex:
create index idx_job on emp(job);

6 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


COMPOSITE INDEX

A composite index also called a concatenated index is an


index created on multiple columns of a table.
Columns in a composite index can appear in any order and
need not be adjacent columns of the table.
Ex:
create index idx_comp on emp(ename,job);

7 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


FUNCTION BASED INDEX

A function-based index is created when using functions or


expressions that involve one or more columns in the table that
is being indexed.
A function-based index pre-computes the value of the function
or expression and stores it in the index.

Ex:
create index idx_ename on emp(upper(ename));

8 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


BTREE INDEX

The default type of index used in an oracle database is the


btree index.
This can be used for highest cardinality ( =1) columns: that is
columns in which the number of distinct values is equal to the
number of the rows in the table.

Ex:
create index idx_empno on emp(empno);

9 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


BITMAP INDEX

When a table has millions of rows and the key columns have
low cardinality.
When queries often use a combination of multiple WHERE
conditions involving the OR operator
When there is read-only or low update activity on the key
columns
Ex:
create bitmap index idx_job on emp(job);

10 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


Questions & Answers

11 Copyright 2014, Oracle and/or its affiliates. All rights reserved.


12 Copyright 2014, Oracle and/or its affiliates. All rights reserved.

You might also like