——添加外键约束
语法:
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);