sql 创建聚集索引和非聚集索引

--创建聚集索引
create CLUSTERED INDEX 索引名称 ON 表名(字段名)

--创建非聚集索引
create NONCLUSTERED INDEX 索引名称 ON 表名(字段名)

--删除指定约束
alter table 表名
drop constraint 主键约束名称

--将指定字段设置成主键非聚集索引
alter table 表名 
add constraint 主键约束名称 primary key NONCLUSTERED(字段名)  

--创建表指定主键为非聚集索引,默认不写NONCLUSTERED为聚集索引
CREATE TABLE Test
( 
  ID INT PRIMARY KEY NONCLUSTERED  --非聚集索引
)

 
 

猜你喜欢

转载自blog.csdn.net/zhou_xuexi/article/details/78028931