Thursday, October 2, 2014

Set table column value as mandatory

I'm creating a table and I'd like to specify a value for a column but as mandatory value, not as default value.


Usually we do someething like this:



CREATE TABLE ABCD
(
MyColumn INT DEFAULT(1)
)



I'd like to do something like this:



CREATE TABLE ABCD
(
MyColumn INT MANDATORY(1)
)

So every Insert or Update that attempts to change this column name fails.


I know that I can achieve this by using a trigger on insert and on update, but I'd like to avoid it, is there any workaround?


No comments:

Post a Comment