——添加外鍵約束
語法:
alter table 表1-表名
add constraint 外鍵名稱(一般外鍵名稱爲”fK_”開頭) foreign key (要設爲外鍵的列名)
references 表2-表名(與哪個表有關聯) (表2中該列列名);
alter table T_Result
add constraint fk_studentId2 foreign key (studentId)
references T_Student (studentId);
alter table t_CardInfo
add constraint fk_customerID foreign key(customerid)
references T_UserInfo (customerid);