具有多个索引名称的相同列。有可能的。有什么用?

问题描述:

对我来说,没有必要/打算为同一列创建多个索引名称。当我正在研究索引时,我尝试了以下测试。有什么用?有什么功能吗?

For me there is no need/intention to create multiple index names for a same column. When i'm studying about index i tried the following test. What is the use of the same? Is there any feature?

我试过的是:


create index id on TestIndex(EmployeeMumber)
create index id1 on TestIndex(EmployeeMumber)
create index id2 on TestIndex(EmployeeMumber)

结果是:命令已成功完成。

The result is: Command(s) completed successfully.

谢谢

SQL Server不会阻止您创建重复索引(尽管没有成功的推动来改变这种情况)。 不会修复可能主要是出于向后兼容性的原因 - 在以前的版本中可能会出现一些用例,人们会在删除旧索引之前创建一个新索引,当像 DROP_EXISTING $这样的选项时会回来c $ c>或在线重建不存在。随着引擎中的新功能的发展,例如 INCLUDE 列,过滤索引等,确定两个索引是否实际上是重复的也更复杂。

SQL Server doesn't prevent you from creating duplicate indexes (though there has been an unsuccessful push to change this). The "won't fix" is probably largely for backward compatibility reasons - there were probably use cases in previous versions where people would create a new index before dropping an old one, back when options like DROP_EXISTING or rebuilding online didn't exist. As new features in the engine evolve, such as INCLUDE columns, filtered indexes, etc. it is also more complex to determine whether or not two indexes are, in fact, duplicates.