Often we need to add a non-nullable column to a table, and it is quite a mission. Using a default constraint as is doesn’t work, so we have to create nullable columns, update them to default values, then make them non-nullable. Is there not an easier way to do this?
Share
Yes, the WITH VALUES modifier to a DEFAULT constraint applies the default value to existing rows, eliminating all the ‘hard’ work described in the question.