?????????????
????????????????????????????д???????????????????κ??????????????????????ù???????д???????κζ??????????????????????????????
????SQL Server???4?????????????????????????????????READ UNCOMMITTED??READ COMMITTED?? REPEATABLE READ??SERIALIZABLE????????4????????????????????????????????????????????????????????????????????????????????????
????READ UNCOMMITTED
?????????????????????????У??????????????????????????????????????????????????д????????????????ζ???????????δ????????????????????ζ????????????????????д???????????????????????????????д???????????????
???????????μ?????1???????????????????
????BEGIN TRAN??
????UPDATE Production.Products SET unitprice += 1.00 WHERE productid = 2;
????SELECT productid?? unitprice FROM Production.Products WHERE productid = 2;
????????????в??id?2?????????е????????????????
????productid   unitprice
????----------  ----------
????2            20.00
??????????????2????????????READ UNCOMMITTED??
????SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED??
????SELECT productid?? unitprice FROM Production.Products WHERE productid = 2;
?????????????£?
????productid   unitprice
????----------  ----------
????2            20.00
????????????1?е????????????????????2????????????δ?????????
????READ COMMITTED
???????????????????????????????????????????????????????????????????????????δ??????????д??????????????????????????????????????????????????????????????ù??????????????????
???????????????????2??
????SET TRANSACTION ISOLATION LEVEL READ COMMITTED??
????SELECT productid?? unitprice FROM Production.Products WHERE productid = 2;
?????????????1???????????????ò???????????????????????ù??????????????????SELECT????????????????????????ж???й???????
????REPEATABLE READ
??????????????????????е??ζ????????????????????????????????REPEATABLE READ??????????????????????????????????????д????????????????????????????????????????κγ?????????????д????????????δ????????????????????????????????????е???????
??????????1??????REPEATABLE READ??????
????SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
????BEGIN TRAN;
????SELECT productid?? unitprice FROM Production.Products WHERE productid = 2;
?????????
????productid   unitprice
????----------  ----------
????2            19.00
????????2????:
????UPDATE Production.Products SET unitprice += 1.00 WHERE productid = 2;
???????????????1????δ????????2??????????????????????????2?е?update?????????
????REPEATABLE READ??????????£??????????????????????????????????????????????????????????????????????????????????е??κ?????????????????????????????
????SERIALIZABLE
????SERIALIZABLE??????????????“???”???????????????????????????????????????????????????????????????е??????????????μ??????????????????????У?????????λ????????Χ?У??????????β??????????????????“???”???????????????SERIALIZABLE???????????????????н???????????????????????Χ??????ζ????????????????????????????????У?????????????С????????????????????????????????????н?????????
????????1???£?
????SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
????BEGIN TRAN;
????SELECT productid?? productname?? categoryid?? unitprice
????FROM Production.Products WHERE categoryid = 1;
??????????£?
????productid   productname        categoryid   unitprice
????----------  ---------------    ----------  ----------
????1           Product HHYDP      1           18.00
????2           Product RECZE      1           19.00
????...
????76          Product JYGFE      1           18.00
????????2???£?
????INSERT INTO Production.Products(productname?? supplierid?? categoryid?? unitprice?? discontinued)
????VALUES('Product ABCDE'?? 1?? 1?? 20.00?? 0);
????????2????????????
?????????а汾???????
????SQL Server????????????????????????а汾????????????SNAPSHOT??READ COMMITTED SNAPSHOT??
?????????????????????а汾?????????????SQL Server ?????tempdb?д洢???????а汾??????????????????
????SNAPSHOT
??????SNAPSHOT???????£?????????????????????????????????????????????а汾??????ζ?????????????????????????????????????????????????????????????????SNAPSHOT????????????????????????????????
????ALTER DATABASE dbname SET ALLOW_SNAPSHOT_ISOLATION ON;
??????????1?У?????????READ COMMITTED?????????2??2??????19.00???20.00??
????BEGIN TRAN;
????UPDATE Production.Products SET unitprice += 1.00 WHERE productid = 2;
????SELECT productid?? unitprice FROM Production.Products WHERE productid = 2;
????????????
????productid   unitprice
????----------  ----------
????2            20.00
????????2????SNAPSHOT??????
????SET TRANSACTION ISOLATION LEVEL SNAPSHOT;
????BEGIN TRAN;
????SELECT productid?? unitprice FROM Production.Products WHERE productid = 2;
????????????????????????????????а汾??
????productid   unitprice
????----------  ----------
????2            19.00
???????????1????????
????COMMIT TRAN;
???????????????20.00?????汾??????μ????汾??
??????????2????ζ?????????????????????????19.00?????????δ????????????????????????????
????productid   unitprice
????----------  ----------
????2            19.00
??????????2?????????′????????
????BEGIN TRAN;
????SELECT productid?? unitprice FROM Production.Products WHERE productid = 2;
????COMMIT TRAN;
??????????????????????????20.00?????????
????productid   unitprice
????----------  ----------
????2            20.00
?????????????汾????????????????????????????????????????