Example: LOCKING Request Modifier and Secondary Indexes - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

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.