Indexes:
Ø Index
on table is used to speed up the execution of queries in the table. This
concept is similar to that of the index in a book.
Ø An
index can be considered as an ordered list of data of a column or a group of
columns, together with a location.
Some of the Indexes are,
1. Simple
Index
2. Composite
Index
3. Reverse
Index
4. Unique
Index
Simple Index:
Ø If
the index is created by using only one column is known as simple index.
Ø Up
to 16 indexes can be used on a table.
Syntax:
Example:
Composite Index:
Ø If
the index is created by more than one column is known as composite index.
Ø Indexed
column of a table can have duplicate values.
Unique Index:
Ø Unique
index used to avoid Duplicate
values.
Syntax:
Example:
Here, Roll_no column does not allow
duplicate values.
Reverse Index:
Ø It
can be done by using “REVERSE” keyword
Syntax:
Example:
Normal Index | Reverse Index |
Empno | Empno |
12345652 | 25654321 |
Alter REVERSE:
Ø Alter
the reverse index into normal.
Example:
Drop index:
Syntax:
Example:
Advantages:
Ø Involving exact
match or range search.
Ø Table occupies
less space.
Ø Key columns are
not duplicated in the table and the index.
No comments:
Post a Comment