0
CREATE NONCLUSTERED INDEX IX_AgentRegistration_Indx2 
ON [AgentRegistration] ([AgencyType], [IsFIT], [IsActive]) 
INCLUDE ([AgencyCode], [AgencyName])
    WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, 
          IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, 
          ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [SECONDARY_NEW]

第二个

CREATE NONCLUSTERED INDEX IX_AgentRegistration_Indx3 
ON [AgentRegistration] ([ExchAgentCode])
   WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, 
         IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, 
         ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 80) ON [SECONDARY_NEW]
4

1 回答 1

1

如果您正在寻找INCLUDE关键字在索引创建中的含义,这里有一个简短的解释:

  • 如果您创建一个复合索引,那么您的索引将包含索引 b 树的所有级别上的两个值;这意味着,查询分析器在做出决策时也将有机会使用这两个值,这可以支持在 WHERE 子句中指定两个列的查询

  • 如果您在一个列上创建索引并且只包含其他列,那么您的索引将仅包含索引 b-tree 的所有级别上的索引列值,并且仅在叶级别,“最后”级别,也会有包含列的值。包含的列值不能用于选择数据 - 它们仅存在于索引叶级别以进行查找。

希望有帮助。

拉詹

于 2013-09-10T05:42:18.473 回答