October 23, 2009 at 8:34 am
it's a simple question, i'm just learning and wanted know if is interesting use 'UNIQUE' in a table that is auto-increment? The values can't repeat
October 23, 2009 at 8:38 am
You don't have to have a unique index on an identity column. It's pretty normal to do so, but not required. Is that what you're asking?
To see this for yourself, try this:
create table #T (
ID int identity);
set identity_insert #T on;
insert into #T (ID)
select 1 union all
select 1;
set identity_insert #T off;
select *
from #T;
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
October 23, 2009 at 9:22 am
Since the reason it is used tends to be so that there is a unique value for the record it is very normal to make it a unique index, often a clustered index..
CEWII
October 23, 2009 at 9:42 am
That's right, thank staff.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply