我想将列季节ID添加到Team表中,默认引用None Season表中的值(我不想说default ='None',而是SeasonID的 将“无”作为“季节年”的行,在该列上放置外键约束。最后,我需要将Fall 2012外键值添加到Season ID列中。
这是我的团队表
teamID teamName
----------- ---------------
100 No Winner
101 Purple Pilots
102 Red Devils
103 Silver Lions
104 Blue Jackets
105 Green Hornets
106 Gold Dragons
这是我的季表
SeasonID SeasonName Year
----------- ---------- ----
100 None 0000
101 Fall 2012
102 Winter 2012
这是我尝试做的,但我可以处理另一个表的默认值
的引用alter table team
add SeasonID int not null;
alter table team
add default 'None'
for SeasonID
alter table team
add constraint team_seasonid_fk foreign key (SeasonID)
references Season(SeasonID)
on update cascade
on delete cascade;
update team
set SeasonID = 101
where SeasonID = 'None';
我该如何正确地做到这一点?