Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I got difference between clustered index and unique index here. But what is the exact difference between clustered index and unique-clustered index?

AFAIK creating clustered index can be done for a column having unique values and if value is duplicate then clustered index cannot be set. Same is the case with unique-clustered index.

So i want to know the difference between them.

share|improve this question

closed as off-topic by Mark Storey-Smith, Kin, Paul White, RolandoMySQLDBA, Marian Dec 29 '13 at 10:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Mark Storey-Smith, Kin, Paul White, Marian
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 3 down vote accepted

You can create a UNIQUE CLUSTERED INDEX only on a column (or combination of columns) that contains no duplicate data. The fact that you create the index with the UNIQUE keyword means that you are now constraining users from adding non unique data. (in the key column(s) of the clustered index)

A CLUSTERED INDEX can be created on a column (or combination of columns) that contains duplicate data. So in this case, the clustered index is not constraining you from adding non unique key data.

However, since a clustered index key is the row identifier, it needs to be able to uniquely identify a row, even if it's created on a column containing duplicate entries. Because of this, if you create a CLUSTERED INDEX for every row that is a duplicate, SQL Server adds a 4 byte uniquifier to the row, so that the index in fact becomes unique. This is all done under the hood.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.