(Contents)(Previous)(Next)

Position-based Access Using a Key

One can think of the rows as being stored in sequential key order. If one key of this sequence is known, it has the function of a pointer. Starting from this pointer, the next or the previous row can be found. The pointer need not necessarily denote an existing key.

SELECT NEXT name FROM city KEY zip = 10580

SELECT PREV name FROM city KEY zip = 90013

Note: If an index was created for any non-key column, such as 'name' (see Section Creating an Index), the stacked job processing of a table can even be performed using this 'secondary key column':

SELECT NEXT zip, name FROM city

INDEX name = 'New York'

KEY zip = 10580

The very first or the very last row can be selected with:

SELECT FIRST name FROM city

SELECT LAST name FROM city

The effect of SELECT FIRST corresponds to the search for the row which in ascending order directly follows the smallest key consisting of binary zeros. SELECT LAST, on the other hand, retrieves the row with the largest key value.


(Contents)(Previous)(Next)