且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何向MS SQL中的现有(填充)表中添加NOT NULL FOREIGN KEY列?

更新时间:2023-11-30 19:53:34

创建列,但允许NULL。
使用外键表中的正确数据填充该列。
改变列添加不为null。
添加外键约束。

Create the column, but allow NULL. Populate the column with the correct data from the foreign key table. Alter the column add not null. Add the foreign key constraint.