Database Reference
In-Depth Information
Figure 32-18.
Data in the
dbo.HKData
table after insert
Let's assume that you have a transaction that started at the time when the
Global Transaction Timestamp
value
was 10 and the
TransactionId
generated as -8. (I am using a negative value for
TransactionId
to illustrate the difference
between two types of timestamps in the figures below.)
Let's assume that the transaction performs the operations shown in Listing 32-8. The explicit transaction has
already started, and the
BEGIN TRAN
statement is not included in the listing. All three statements are executing in the
context of a single active transaction.
Listing 32-8.
Data modification operations
insert into dbo.HKData with (snapshot)
(ID, Col)
values(10,10);
update dbo.HKData with (snapshot)
set Col = -2
where ID = 2;
delete from dbo.HKData with (snapshot)
where ID = 4;
Figure
32-19
illustrates the state of the data after data modifications. An
INSERT
statement created a new row, a
DELETE
statement updated the
EndTs
value in the row with
ID=4
, and an
UPDATE
statement changed the
EndTs
value of
the row with
ID=2
and created a new version of the row with the same
ID
.
Figure 32-19.
Data in the
dbo.HKData
table after modifications