创建聚集索引(clustered)和非聚集索引(nonclustered)

来源:互联网 发布:初学瑜伽哪个软件好 编辑:程序博客网 时间:2024/05/20 14:24

创建聚集索引:物理存储顺序,因此一个表中只能包含一个聚集索引。但该索引可以包含多个列,也就是所谓的组合索引。

非聚集索引:数据存储和索引存储存放在不同的地方,类似于课本中的索引。表中可以包含多个非聚集索引

   例子:
          (1) 给 student 数据库中 me 表的 name 列创建一个非聚集索引 student_form

          use student

          if exists(select name from sysindexes where name = 'student_form')
                     drop index me.student_form;

          // 默认为创建 非聚集索引(nonclustered)
          create index student_form on me(name) <==> create nonclustered index student_form on me(name)

原创粉丝点击