Index Enhancements   «Prev  Next»
Lesson 3 Create a descending index
Objective Create a descending index.

Create Descending Index in Oracle

In a normal, B*-tree index, the values are always stored in sorted order. The sorted nature of the B*-tree index is a requirement for the structure of the B* tree; navigation through the tree is based on the sorted values. Of course, the fact that values in an index are stored in sorted order helps to improve query performance, because a query that requests sorted results can simply use the appropriate index, if available, to avoid the overhead of resorting the data.
Prior to Oracle, all B*-tree indexes were sorted in ascending order. There are certainly times when queries might require data to be sorted in descending order. For instance, if a value were an ID number that increased over time, and a user wanted a list of orders sorted from the most recent order to the lease recent order, he or she would specify that the query return data sorted descending on the ID number.

Syntax

To create a descending index, you simply specify the keyword DESC at the end of a normal CREATE INDEX statement, as shown in the following ToolTip:

  1. Required keywords
  2. The unique name of the index
  3. Required keyword
  4. The unique name of the table on which the index is based
  5. A list of columns that make up the index
  6. A keyword that denotes that the column is stored in descending order
CREATE INDEX index_name ON table_name
  (column_list) DESC;

Oracle Descending Index
In the next lesson, you will learn about some of the improvements in Oracle’s bitmapped indexes.

Creating Descending Index - Exercise

Click the Exercise link below to practice creating a descending index.
Creating Descending Index - Exercise