为什么不能使用 online=on 选项删除非聚集索引

Bat*_*ech 8 sql-server sql-server-2008-r2 nonclustered-index

尝试使用联机选项(例如 )删除非聚集索引时DROP INDEX [IX_MYINDEX] ON [dbo].[myTable] WITH ( ONLINE = ON ),我收到以下错误消息。

Msg 3745, Level 16, State 1, Line 16 
Only a clustered index can be dropped online.
Run Code Online (Sandbox Code Playgroud)

SQL Server 文档明确指出:

只有在删除聚集索引时才能指定 ONLINE 选项。

https://msdn.microsoft.com/en-us/library/ms176118.aspx

但是有人可以向我解释为什么会这样吗?根据我的经验,与聚集索引相比,您更有可能删除非聚集索引,因为在大多数情况下聚集索引也是您的主键。

Rem*_*anu 12

因为删除 NCI 已经尽可能多地在线。是仅元数据操作。甚至没有数据删除,删除的索引行集只是被释放,即。与 truncate 相同的操作。

另一方面,删除聚集索引意味着重建并且是数据大小的操作,因此有一个在线替代方案确实有意义。