17.05 - Example: LOCKING Request Modifier and Secondary Indexes - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

The system synchronizes base data rows and index subtable rows. However, an ACCESS lock can allow inconsistent results even when secondary indexes are used in conditional expressions because index constraints are not always rechecked against the data row.

For example, a column named qualify_accnt is defined as a secondary index for a base table named accnt_rec, as in the following request:

     LOCKING TABLE accnt_rec FOR ACCESS
     SELECT accnt_no, qualify_accnt
     FROM accnt_rec
     WHERE qualify_accnt = 1587;

The request could return:

     accnt_no     qualify_accnt
     --------     -------------
         1761              4214

In this case, the value 1587 was found in the secondary index subtable and the corresponding data row was selected and returned. However, the data for account 1761 had been changed by another user while the retrieval was in process. This is referred to as a dirty read. See Teradata Vantage™ - SQL Request and Transaction Processing, B035-1142.

Anomalous results like these are possible even if the data is changed only momentarily by a transaction that is ultimately aborted. The ACCESS lock is most useful to those who simply want an overview of data and are not concerned with consistency.