Specifying Index Sort Order (Embedded SQL Guide)
Go Up to Creating an Index
By default, SQL stores an index in ascending order. To make a descending sort on a column or group of columns more efficient, use the DESCENDING
keyword to define the index. For example, the following statement creates an index, CHANGEX
, based on the CHANGE_DATE
column in the SALARY_HISTORY
table:
EXEC SQL CREATE DESCENDING INDEX CHANGEX ON SALARY_HISTORY (CHANGE_DATE);
- Note: To retrieve indexed data in descending order, use
ORDER BY
in theSELECT
statement to specify retrieval order.