首页 > 其他 > 详细

引用完整性

时间:2021-04-19 11:49:35      阅读:7      评论:0      收藏:0      [点我收藏+]

##引用完整性

学生表

   Id

   名字

   性别

 

成绩表

   Id

   学生ID

  成绩

 

Create table stu7

   Id int primary key;

   Name varchar(50)

)

Create table score(

      Id int primary key,

      Sid int,

      Score double,

      Constraint as foreign key(sid) references stu7(id)

)

 

Insert into stu7(id,name) values(1,zsf);

Insert into score(id,sid,score) values(1,1,90);

 

ERROR 1452 (23000):Cannot add or update a child

Row:a foreign key constraint fails (db_0402,score;

 CONSTRAINT aaFOREIGN KEY (sid)REFERENCESstu7(id))

 

引用完整性

原文:https://www.cnblogs.com/zsrr/p/14675438.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!