Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
好的,这是一个非聚集索引功能
现在您可以看到 Id 是作为主键和聚集的身份列。我可以将它包含到索引列中并将索引标记为唯一,或者不将其包含到索引本身并将其添加为包含列。
应该选择哪一个,为什么?谢谢你
聚簇键会自动包含在非聚簇索引中,无论您是否显式包含它。换句话说 - 不要包含它,除非您需要使用一个谓词来过滤聚集键,然后是几个其他列(按此顺序) - 在这种情况下,强制它作为第一列可能是有意义的,否则它将作为最后一列物理存储。