设非主键为聚集索引

----设置非主键为聚集索引【4步】 转自:http://king123654789.iteye.com/blog/1169191

1. 查看所有的索引,默认情况下主键上都会建立聚集索引
sp_helpindex person

2. --删除主键约束,把【1】中查询出的主键上的索引约束【如:PK__person__117F9D94】去除掉。去掉主键字段上面的主键约束,此时该字段不是主键了。
alter table person drop constraint PK__person__117F9D94

3.--创建聚集索引到其它列
create clustered index test_index on person(date)

4.—修改原来的主键字段还是为主键,此时会自动建立非聚集索引【因为已经有了聚集索引】
alter table person add primary key (id)

SQL Server 索引结构及其使用(一)

SQL Server 索引结构及其使用(二)

SQL Server 索引结构及其使用(三)

SQL Server 索引结构及其使用(四)

 

原文地址:https://www.cnblogs.com/cpcpc/p/2851275.html