索引

Posted on 2021-05-28 11:22  夜雨初凉  阅读(32)  评论(0)    收藏  举报

索引(好比书本的目录)

功能:提高查询效率

创建聚集索引

create clustered index cluNameindex on dbo.StuInFo(name)
  • 聚集索引只能有一个
  • 主键自带聚集索引

★ 因为有主键自带了一个聚集索引,无法添加聚集索引

创建非聚集索引

create nonclustered index cluindexname on dbo.StuInFo(name)
with fillfactor=70
  • fillfactor 填充因子
    1.低更改的表(读写比率为100:1):100%的填充因子;
    2.高更改的表(写超过读):50-70%的填充因子;
    3.读写各一半的:80-90%的填充因子。

通过非聚集索引查询

select * from dbo.StuInFo 
with(index =cluindexname)
where 条件

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3