在数据库中,键和索引之间有什么区别? [英] In a database, what is the difference betwen a key and an index?
本文介绍了在数据库中,键和索引之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,在SQLServer中,如果我有一个设置了unique的索引,那么这个不同于key的是什么?
For example, in SQLServer, if I have an index with 'unique' set on it, how is that different from a key?
我想使用键与索引字段?
How do I know when I want to use a Key vs. an Indexed field?
推荐答案
具有唯一值的字段基本上是一个键。但是,一个键用于唯一标识表中的行,而索引用于对表中的行进行排序或分组。一旦初始设置,密钥不应该更改,因为它可能在数据库中的其他地方引用。然而,索引字段可以自由更改。
An field which has unique values is, essentially, a key. However, a key is used to uniquely identify a row in a table, while an index is used to sort, or group, the rows in the table. A key should not change once it has been initially set, as it might be referenced to elsewhere in your database. An indexed field, however, can change freely.
这篇关于在数据库中,键和索引之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文