Clustered or non-clustered primary key in SQL Server?

1136695 pts.
Tags:
SQL Server
For SQL Server, I'm creating a test database and I'm debating if I should use NONCLUSTERED or CLUSTERED primary key. What's the difference between the two? Is there a preference of one over the other?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

Please go through the following link. You can read brief information over there.
https://msdn.microsoft.com/en-us/library/ms190457.aspx

————-

A clustered index sorts and stores the data rows in the table based on their key values, or in other words, the data is actually stored in the order of the index, so that is why you can only have one clustered index for each table.

When you create a primary key, a clustered index is created by default (if one doesn’t exist), so clustered is the default type of index for a PK (you can choose to use a non-clusetered, though).

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TheRealRaven
    There is a preference if you want an index to be clustered or not. If you don't care, then there is no preference. It's up to you to decide for any given index. (Only one index for a given table can be clustered.)

    Numerous factors can influence your choice. It's often useful to pick an index as the clustered one, but it usually should be one that will be accessed in the order of the index more than others.

    You might not want your system to be spending its time reordering physical rows. The volume of inserts/deletes (or perhaps updates), the number of rows in the table(s) and other factors can come into it.
    34,320 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: