一、創建索引
1、聚集索引
create clustered index 索引名稱 on 表名(列A,列B,...)
2、非聚集索引
create nonclustered index 索引名稱 on 表名(列A,列B,...)
二、刪除索引
drop index 索引名稱 on 表名
三、將主鍵的聚集索引改成非聚集索引
--刪除主鍵約束
alter table 表名 drop CONSTRAINT 索引名稱
--重建主鍵約束
alter table 表名 add CONSTRAINT 索引名稱
PRIMARY KEY NONCLUSTERED (列名)
四、建立包含性列索引
CREATE nonclustered INDEX 索引名稱 ON inspection_detail (列A,列B,...)
INCLUDE (包含性列)
注意:只能是非聚集索引