且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

主键和集群索引之间的关系

更新时间:2023-11-03 10:17:10

表上的主键为每一行提供唯一标识符。索引(群集或非群集)用于在读取数据时提高性能。如何设置索引在很大程度上取决于您将如何读取数据...这可能涉及或可能不涉及主键,但通常不涉及。

例如在包含的表中客户数据,您可能会给每个客户一个唯一的号码,但是对于搜索,您可能想要为他们的姓氏编制索引。



这些链接提供更多详细信息

https://www.simple-talk.com / sql / learn-sql-server / sql-server-index-basics / [ ^ ]



http://blog.sqlauthority.com/2013/02/10/sql -server-primary-key-and-nonclustered-index-in-simple-words / [ ^ ]
A primary key on a table provides a unique identifier for each row. An index (clustered or non-clustered) is used to aid performance when reading the data. How you set up an index largely depends on how you are going to read the data ... this may or may not involve the primary key, but frequently doesn't.
For example in a table containing Customer data, you might give each customer a unique number, but for searching you would probably want to index on their surname.

These links give further details
https://www.simple-talk.com/sql/learn-sql-server/sql-server-index-basics/[^]

http://blog.sqlauthority.com/2013/02/10/sql-server-primary-key-and-nonclustered-index-in-simple-words/[^]