SQL Server??????????
???????????? ???????[ 2016/10/12 10:45:24 ] ????????????? SQL Server
???????????????
???????????????????????????????????????????????????????????????????
????USE master;
????ALTER DATABASE AdventureWorks
????SET ALLOW_SNAPSHOT_ISOLATION ON;
???????????????????????Щ????Sales.SalesOrderDetail????????????????????????????????????????????????????????????????к??????????OrderTotal?????
????USE AdventureWorks;
????SET TRANSACTION ISOLATION LEVEL SNAPSHOT
????BEGIN TRAN
????SELECT SUM(LineTotal) as OrderTotal
????FROM Sales.SalesOrderDetail
????WHERE SalesOrderID = 43659
????????SNAPSHOT????壺
????1. ??????????κ????????????????????????????????????????????μ?汾???????????????儷???????????????????????????е???佫????????????????????????????????????????????Ч???????????е???????????????????????????????????????????
????2. ??????????????????? SNAPSHOT ??????????????????????????????? SNAPSHOT ?????????????????д???????д??????????????????? SNAPSHOT ???????????
????3. ???????????????Σ????????????????????????????????????????? SNAPSHOT ??????????????????????????????SNAPSHOT ????????????????????????????????????????????
????4. ???? ALLOW_SNAPSHOT_ISOLATION ????????????? ON?????????????? SNAPSHOT ????????????????? SNAPSHOT ??????????????????????е??????????????????????н? ALLOW_SNAPSHOT_ISOLATION ??????? ON??
????5. ?????????????????????????????? SNAPSHOT ??????????????????????????????????? SNAPSHOT ????????????????????????????????????????? SNAPSHOT????????????? BEGIN TRANSACTION ??儷???
????6. ?? SNAPSHOT ???????????е?????????????????????????????磬???????????? UPDATE??????????????? SELECT ??????????????????????????С?
???????????????????????SalesOrderDetail?????????????1???????????????(???????????????????OrderQty???5???????????????????′????????????????????е?????)??
????USE AdventureWorks;
????UPDATE Sales.SalesOrderDetail
????SET OrderQty = 5
????WHERE SalesOrderID = 43659
????AND ProductID = 777
?????????????2???л??????????1?????????????SELECT???
????SELECT SUM(LineTotal) as OrderTotal
????FROM Sales.SalesOrderDetail
????WHERE SalesOrderID = 43659
?????????????????????????????????????й???????????????????????????????????????????????????????????????
???????????????????′????????????????????????????????????????????????????仯??
????COMMIT TRAN
????SELECT SUM(LineTotal) as OrderTotal
????FROM Sales.SalesOrderDetail
????WHERE SalesOrderID = 43659
??????????′?????AdventureWorks??????????????
????ALTER DATABASE AdventureWorks
????SET ALLOW_SNAPSHOT_ISOLATION OFF;
???????????????????????
??????????????????????????????????????????????????????????????????????????????Щ????£??б???????????????й????????????????????????????????????????????????????????????????????????????????????????????????????????£???????????????????????????????????????????????????£?????????????????????????????????????????????????????????????????????????????п?????????????????????????????????????????????????????????????????????????
???????????????????
???????????????OrderID?43659?????????????????????????????????????????????????????????????????
????USE AdventureWorks;
????SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
????BEGIN TRAN
????SELECT SalesOrderID?? SalesOrderDetailID?? ProductID?? OrderQty
????FROM Sales.SalesOrderDetail
????WHERE SalesOrderID = 43659
????????REPEATABLE READ????壺
????1. ????????????????????????????δ?????У???????????????κ??????????????????????????????????????????
????2. ???????е???????????????????????????????????????ù???????????????????????????????????????????????????????κ??С?????????????????????????????????????????????????С????????????????????и??????????????У?????????????????????????????????????????????????????????????????????????????? READ COMMITTED ???????????????????á?
?????????????????????????′????????SalesOrderDetail?????????????1???????????????
????UPDATE Sales.SalesOrderDetail
????SET OrderQty = 5
????WHERE SalesOrderID = 43659
????AND ProductID = 777
????????????????????????????????????????????????????????????????????????????????????????ù?????????sys.dm_tran_locks????
?????????????????"?????в??"??????????????2?е??????????????INSERT?????????м???????????
????INSERT INTO Sales.SalesOrderDetail
????(
????SalesOrderID??
????CarrierTrackingNumber??
????OrderQty??
????ProductID??
????SpecialOfferID??
????UnitPrice??
????UnitPriceDiscount
????)
????VALUES(43659??'4911-403C-98'??1??758??1??874??0)
?????????????????????????????????????????С?????????????????????????????????£???INSERT???????????в???????????????????????д?????????1??????SELECT????????Χ??У????????????????λ????????????????????????????????
???????SELECT?????????????????????
????SELECT SalesOrderID?? SalesOrderDetailID?? ProductID?? OrderQty
????FROM Sales.SalesOrderDetail
????WHERE SalesOrderID = 43659
????COMMIT TRAN
???????????????б?SELECT????????????????????????????Χ???????????????????????????????????????????????????SELECT????????Χ???
????????
????SET TRANSACTION???????????????
????SET TRANSACTION ISOLATION LEVEL
????{ READ UNCOMMITTED
????| READ COMMITTED
????| REPEATABLE READ
????| SNAPSHOT
????| SERIALIZABLE
????}
????[ ; ]
????????????????????????????????????
????1.READ UNCOMMITTED
?????????????????????????????????δ?????С?
?????? READ UNCOMMITTED ???????е????????????????????????????????????????????????READ UNCOMMITTED ????????????????????????????????????????????????????????δ?????С??????????????????δ???????????????????????????????????????????????е??????????????????????л?????????????????????????????????????? SELECT ????е????б??????? NOLOCK ??????????????????????????
?????? SQL Server 2005 ?У????????????????????????????????????????δ???????????????????????????????
????1. READ COMMITTED ?????????? READ_COMMITTED_SNAPSHOT ????????????? ON??
????2. SNAPSHOT ??????
????1.READ COMMITTED
????????????????????????????????δ???????????????????????????????????????????????????????????????????????????????????????????????? SQL Server ????????á?
????READ COMMITTED ?????????? READ_COMMITTED_SNAPSHOT ??????????????
????1. ????? READ_COMMITTED_SNAPSHOT ????? OFF??????????????????????? ????ù??????????????????????????ж?????????????С???????????????????????????????????????Щ?????????С????????????????????
????2. ????? READ_COMMITTED_SNAPSHOT ????? ON????????????? ??????а汾??????????????????????????μ??????????????????????儷???????????????????????????????????
?????? READ_COMMITTED_SNAPSHOT ????????????? ON ???????????? READCOMMITTEDLOCK ?????? READ_COMMITTED ???????????е??????е??????????????????????а汾?????
??????????? READ_COMMITTED_SNAPSHOT ????????????н??????????? ALTER DATABASE ???????????? ALTER DATABASE ?????????????в??????????????????????????????????????
????1.SERIALIZABLE
??????????????????
????1. ?????????????????????????δ?????????
????2. ?κ??????????????????????????????????????????????
????3. ?????????????????????????????????????κ?????????????????С?
??????Χ????????????????е??????????????????????????Χ???????????????????????????????κ??У??????????????????е??κ????????ζ????????????????е??κ????????Щ????????????С?????????????????????Χ???????????????????????????????????????Χ??????????????????????Χ????????????????????????????????????????????????????????????? SELECT ????е????б??????? HOLDLOCK ?????
???????????????
????1. ??????????????????????????????????????????????????Ч????????????????????????????е????ж???????????????????????????????У????????? FROM ????е??????????????????????????汾?????????
????2. ????????????????????????????????????? READ COMMITTED ?? REPEATABLE READ ???????????????????????????????????????д??????????????????????????????????????????????????????????????????????????????????????е???????????????????????????????????????????磬??? REPEATABLE READ ?????????????е???????????????????????????У??????????????????????????
????3. ????????????????????????????????????л?????????????????????????????????????????????? SNAPSHOT ???????????????????????????????????????????????????????? SNAPSHOT ????????????????????κ???????????
????4. ???????????????????????????????????????????????????????????????б????????????????????????????????????????????????????磬??????????? READ COMMITTED ????? SERIALIZABLE?????????????????????????????????????????????????
????5. ?????洢??????????з??? SET TRANSACTION ISOLATION LEVEL???????????????????????????????????????Ч????????磬????????????????? REPEATABLE READ???????????????????????????????? SERIALIZABLE ??洢?????????洢?????????????????????????????????? REPEATABLE READ??
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???????sql server 2000??????????????SQL Server???????????????????λ?????SQL Server??????????????????????????????SQL Server??Azure SQL??SQL SERVER ?????????????汾??????SQL Server??WITH (NOLOCK)SQL Server??????????????DML??????????SQL Server????????????????????SQL Server??????SQL Server???????????Ч?????????SQL Server?????????????????SQL Server?????????????????SQL Server????????SQL SERVER????????SQL Server????δ???????SQL SERVER??????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????