February 4, 2011 at 1:13 pm
Happy Friday!
I am working on database, which has some weird Default constraints defined on columns that allow for NULL values:
ALTER TABLE [dbo].[TableName] ADD CONSTRAINT [DF_TableName_ColumnName] DEFAULT (NULL) FOR [ColumnName]
Can you please help me understand:
1) what could be a meaning behind having this kind of constraint, since NULL is inserted anyways, if value is not passed
2) why would SQL Server lets you create this meaningless constraint?
3) is there any performance implications/or other downsides of having this kind of constraint on a table?
Thanks,
Marianna
February 4, 2011 at 1:26 pm
I guess it follows the "explicit is better than implicit" rule of thumb, but otherwise, there's no benefit I can think of to it.
- 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
February 4, 2011 at 1:28 pm
Thanks for you response -- I agree with the "benefit" part, but would the be any downside that you can think of?
February 4, 2011 at 1:38 pm
Almost certainly not. Try some tests on your hardware, see if it has any impact at all. I doubt it will.
- 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
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply