在线等 SQL语句什么意思?
alter table cam add ctrl_userid_fk int null;
alter table cam add constraint FK_cam_ctrl_userinfo FOREIGN KEY (ctrl_userid_fk) REFERENCES userinfo(userId_pk);
------解决方案--------------------为cam 添加一个int列ctrl_userid_fk
并将其作为外键与userinfo表的userId_pk列关系(ctrl_userid_fk列的值都来自userId_pk列)
------解决方案--------------------1.alter table cam add ctrl_userid_fk int null;
2.alter table cam add constraint FK_cam_ctrl_userinfo FOREIGN KEY (ctrl_userid_fk) REFERENCES userinfo(userId_pk);
1.在CAM表中加一个INT型的列,名叫ctrl_userid_fk
2.为新加的这一列加一个约束,它是一个外键,绑定到userinfo表中的userId_pk列. constraint FK_cam_ctrl_userinfo 意思是你建了一个约束,名字叫做FK_cam_ctrl_userinfo
如果你往cam表中加一条记录时,ctrl_userid_fk这一列的值必须是在userinfo表中的userId_pk列中存大的值,不然添加操作会失败.