????????????????????????????????????? Online Index Rebuild operations??????????SQL Server 2014????????????????????????????SQL Server 2005??????????????????????????????Щ????????????????????????????????????????SQL Server?????ù????????Shared Table Lock (S) ??????????????????????????ü?????????Schema Modification Lock (Sch-M) ?????????Щ????????????????????????????????marketing trick????????????“????”?????“????????”?????????
????????????SQL Server 2014?????????????????????????????????????????Щ????????????????????????????????????????ν???????????Lock Priority????????????????????????????????????
????1 ALTER INDEX idx_Col1 ON Foo REBUILD
????2 WITH
????3 (
????4    ONLINE = ON
????5    (
????6       WAIT_AT_LOW_PRIORITY
????7       (
????8          MAX_DURATION = 1??
????9          ABORT_AFTER_WAIT = SELF
????10       )
????11    )
????12 )
????13 GO
???????????????????????????WAIT_AT_LOW_PRIORITY??????????δ????????1??????MAX_DURATION????????????????——??????????????????ABORT_AFTER_WAIT???????????????????SQL Server?????SELF??ζ?????ALTER INDEX REBUILD???????????????BLOCKERS????????????????????????????????????????????????????????????С???????????????????????????????????????
???????????????????????????????????????????????????????????
1 -- Creates a new database
2 CREATE DATABASE Test
3 GO
4
5 -- Use the database
6 USE Test
7 GO
8
9 -- Create a simple table
10 CREATE TABLE Foo
11 (
12     Col1 INT IDENTITY(1?? 1) NOT NULL??
13     Col2 INT NOT NULL??
14     Col3 INT NOT NULL
15 )
16 GO
17
18 -- Create a unique Clustered Index on the table
19 CREATE UNIQUE CLUSTERED INDEX idx_Col1 ON Foo(Col1)
20 GO
21
22 -- Insert a few test records
23 INSERT INTO Foo VALUES (1?? 1)?? (2?? 2)?? (3?? 3)
24 GO
????????????????????????????????μ?????????????
????1 BEGIN TRANSACTION
????2
????3 UPDATE Foo SET Col2 = 2
????4 WHERE Col1 = 1
????????ζ?????????????????????????????Exclusive Lock (X)???????????????????????????Intent-Exclusive Lock (IX)????????????????????????Intent-Exclusive Lock (IX)????????????SQL Server????????????????Σ?locking hierarchy??????=>?=>????????????????????????IX Lock???????????????????????????????Shared Lock??????????——???????/???????η?????????????????????????????????????????????
????1 ALTER INDEX idx_Col1 ON Foo REBUILD
????2 WITH
????3 (
????4    ONLINE = ON
????5 )
????6 GO