Bhavik Goyal
Bhavik Goyal

Reputation: 2796

Benefits of using Identity Column instead of Unique Key

I want to know the advantages of using the identity column on Unique Key. I have always used the identity column, and know it is better than Unique Key. But I want to know the benefits of Identity key over unique key.

Thanks

Upvotes: 1

Views: 2331

Answers (2)

dwilson
dwilson

Reputation: 361

Are you trying to decide between using an identity column vs. a uniqueidentifier column as a primary key?

Uniqueidentifier (Guids) have the advantage of being unique across the entire environment, making it easier to uniquely identify a record outside of the context of a given table. They also provide a key you can expose in your applications which are not easily iterated.

Identity columns use less storage and are therefore faster and more efficient.

There is no right answer for their use. It really depends on the context.

Upvotes: 2

Brian Salta
Brian Salta

Reputation: 1576

A primary key can be used as a foreign key in another table, an identity column cannot. Without seeing the type of data you are trying to store, I would recommend using an identity column but also setting that as your primary key.

Upvotes: -1

Related Questions