LoslegenKostenlos loslegen

Preventing non-repeatable reads

You are in charge of analyzing data about your bank customers.

You prepare a script that first selects the data of every customer. After that, your script needs to process some mathematical operations based on the result. (We won't focus on these operations for this exercise.) After that, you want to select the same data again, ensuring nothing has changed.

As this is critical, you think it is better if nobody can change anything in the customers table until you finish your analysis. In doing this, you prevent non-repeatable reads.

Diese Übung ist Teil des Kurses

Transactions and Error Handling in SQL Server

Kurs anzeigen

Anleitung zur Übung

  • Set the appropriate isolation level to prevent non-repeatable reads.
  • Begin a transaction.
  • Commit the transaction.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

-- Set the appropriate isolation level
___ ___ ___ ___ ___ ___

-- Begin a transaction
___ ___

SELECT * FROM customers;

-- some mathematical operations, don't care about them...

SELECT * FROM customers;

-- Commit the transaction
___ ___
Code bearbeiten und ausführen