通常在SQL Server Management Studio中,通过设置主键来创建聚集索引,但是我的最近一个关于PK <-> 聚集索引 (Meaning of Primary Key to Microsoft SQL Server 2008) 的问题表明,将PK和聚集索引设置为相等并非必要。
那么我们应该如何选择聚集索引呢?让我们看以下示例:
create table Customers (ID int, ...)
create table Orders (ID int, CustomerID int)
通常我们会在两个ID列上创建主键/唯一约束,但我考虑在CustomerID上为Orders创建它。这是最好的选择吗?