Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
Hi,
we can have primary key and cluster index on same table with different field so my question is in that scenario, would data be stored on the disk on the basis of Cluster index or primary key if it is on the basis of Cluster index(and that's the reason a table can have only one cluster index??) then what would be the role of Primary key in the table??

I mean we say that a table can have only one primary key because data can be stored on the disk in only one particular order so is this statement is true on the above scenario??

I hope I am not sounding confuse here.
Posted
Updated 10-Nov-13 3:55am
v2
Comments
OriginalGriff 10-Nov-13 9:55am    
What the heck does this have to do with Interfaces or Abstract classes? This is all SQL!

1 solution

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/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900