i adding new column in existing table preloaded data. column uses primary key table , want default 5. have tried following code:
alter table group add group_type int go alter table group add constraint fk_group_type default 5 group_type go
i expecting on alter of group table values filled 5 instead null. doing wrong?
first of all, adding default constraint (in it's own sql statement) column not effect existing data in column. effects new inserts table not provide value column.
second, haven't created foreign key constraint here.
edit:
here 1 way create fk correctly
alter table group add group_type_id int go alter table group add constraint fk_grouptype foreign key (group_type_id) references group_type (group_type_id)
Comments
Post a Comment