聚集索引和唯一索引有什么区别? [英] what is a difference between Clustered Index and Unique Index?

查看:52
本文介绍了聚集索引和唯一索引有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在学习 SQL Server 中的索引,但对聚集索引和唯一索引之间产生了混淆.如果两者都应用于唯一键列,例如:PersonID.那么两者有什么区别.

I am just learning about Indexing in SQL server but got confuse between Clustered and Unique index. if both are applied on a unique key column ex: PersonID. so what is difference between both.

谢谢.

推荐答案

唯一索引只是具有唯一约束的索引,仅此而已.聚集索引对磁盘上的数据进行物理排序以匹配索引.如果您经常通过一列访问表中的数据,这很有用,例如通过主键.同样一张表只能有一个聚集索引(当然很明显).

A unique index is just an index with a unique constraint, nothing more, nothing less. A clustered index orders the data phsyically on the disk to match the index. It is useful if you access the data in the table very often via just one column, e.g. via the primary key. Also a table can have only one clustered index (obvious, of course).

这篇关于聚集索引和唯一索引有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆