Sql server® 2012 t-sql fundamentals



Download 10,93 Mb.
Pdf ko'rish
bet349/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   345   346   347   348   349   350   351   352   ...   443
Bog'liq
BookSQL

 

CHAPTER 9

 

Transactions and Concurrency



 

 311

BEGIN TRAN; 

 

  UPDATE Production.Products 



    SET unitprice += 1.00 

  WHERE productid = 2; 

 

  SELECT productid, unitprice 



  FROM Production.Products 

  WHERE productid = 2;

Note that the transaction remains open, meaning that the product’s row is locked exclusively by 

Connection 1. The code in Connection 1 returns the following output showing the product’s new 

price.

productid   unitprice 



----------- --------------------- 

2           20.00

In Connection 2, run the following code to set the isolation level to READ UNCOMMITTED and 

query the row for product 2.

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; 

 

SELECT productid, unitprice 



FROM Production.Products 

WHERE productid = 2;

Because the query did not request a shared lock, it was not in conflict with the other transaction. 

This query returned the state of the row after the change, even though the change was not committed.

productid   unitprice 

----------- --------------------- 

2           20.00

Keep in mind that Connection 1 might apply further changes to the row later in the transaction 

or even roll back at some point. For example, run the following code in Connection 1 to roll back the 

transaction.

ROLLBACK TRAN;

This rollback undoes the update of product 2, changing its price back to 19.00. The value 20.00 

that the reader got was never committed. That’s an example of a dirty read.


Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   345   346   347   348   349   350   351   352   ...   443




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish