Aan de slagGa gratis aan de slag

Using the READ UNCOMMITTED isolation level

A new client visits your bank to open an account. You insert her data into your system, causing a script like this one to start running:

BEGIN TRAN

  INSERT INTO customers (first_name, last_name, email, phone)
  VALUES ('Ann', 'Ros', '[email protected]', '555555555')

  DECLARE @cust_id INT = scope_identity()

  INSERT INTO accounts (account_number, customer_id, current_balance)
  VALUES ('55555555555010121212', @cust_id, 150)

COMMIT TRAN

At that moment, your marketing colleague starts to send e-mails to every customer. There is going to be a raffle for a car! The script he executes gets every customer's data, including the last customer you inserted. This script starts running after the first insert occurs but before the COMMIT TRAN.

How can that be?

Deze oefening maakt deel uit van de cursus

Transactions and Error Handling in SQL Server

Cursus bekijken

Oefeninstructies

  • Set the READ UNCOMMITTED isolation level.
  • Select first_name, last_name, email and phone from customers table.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

-- Set the appropriate isolation level
___ TRANSACTION ___ LEVEL ___ ___

	-- Select first_name, last_name, email and phone
	SELECT
    	___, 
        ___, 
        ___,
        ___
    FROM customers;
Code bewerken en uitvoeren