Hi friends,
I want to know What's the difference between a primary key and a clustered index?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Jun 4, 2012, 1:58 AM EDT
When you create the primary key on table then, it will create the clustered index. You can have only one clustered index per table.
Since you can have only one primary key. At the same time you can create the clustered index by CREATE CLUSTERED INDEX statement.
When you have clustered index on the table when every you do DML operation, it will do sorting automatically based on clustered index column.
The clustered node will have the value.
Anil KumarRank #367 · 6.8K reputationPosted Jun 4, 2012, 2:26 AM EDT
A primary key with non-clustered index may gives good performance over clustered primary key in some scenario. You may have a clustered indexing on other column (not with primary) which is mostly using for range search and your primary key with non-clustered index. All depends upon the requirements!!!
Clustered Index: For clustered index, column doesn't need to be unique. Please re-read last line. Clustered index column may contain duplicate values, Null values!!!. There is no problem at all. This is not possible with Primary key. A primary key can't have null or duplicate values.
Anil KumarRank #367 · 6.8K reputationPosted Jun 4, 2012, 3:01 AM EDT
And may not have any index also. !!!
Or can have both or any one.
Check indexes on a table using this -
EXEC sp_helpindex