SqlServer的三个索引简单说明及其使用

简介:

1、unique:唯一索引,该字段的每个记录的值都不能重复。

2、clustered:聚集索引,可以包含多个列,比非聚集索引要快,但是每个表只能有一个。

3、nonclustered:非聚集索引,单列使用,可以提高检索性能,但是会增加硬盘存储的数据,也就是说空间换时间

使用方式:

CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name   
    ON <TABLE_NAME> ( column_name [ ASC | DESC ] [ ,...n ] )   
    [ WITH <backward_compatible_index_option> [ ,...n ] ]  
    [ ON { filegroup_name | "default" } ]  

简单的例子:

create clustered index index_name
on table_name (column_name)

使用建议:

 

posted @ 2018-04-27 09:44  范海辛Z  阅读(1457)  评论(0编辑  收藏  举报