标题:MYSQl中修改数据出问题了!
只看楼主
david168520
Rank: 2
来 自:湖北
等 级:论坛游民
帖 子:227
专家分:50
注 册:2009-2-16
结帖率:100%
 问题点数:0 回复次数:0 
MYSQl中修改数据出问题了!
create table student(number varchar(10) not null primary key,name varchar(10) not null,loanNumber varchar(10),
ID varchar(20) not null,sex varchar(5) not null,birthday varchar(50) not null,enterSchoolTime varchar(50) not null,address varchar(50),
postID varchar(10) not null,telNumber varchar(15),class varchar(50),academy varchar(50),major varchar(20),
loanType int,loanAmount int,loanState varchar(10))TYPE=INNODB;这是学生信息表

create table loan(loanNumber varchar(10) ,name varchar(10) not null,number varchar(10) not null ,
applyLoanTime varchar(20) not null,
class varchar(50),academy varchar(50),major varchar(20),
loanType int,loanAmount int,loanState varchar(10),primary key(number,loanNumber))TYPE=INNODB;这是学生贷款信息表

create unique index index_loan on loan(loanNumber,name,number,class,academy,major,loanType,loanAmount,loanState);
create unique index index_student on student(loanNumber,name,number,class,academy,major,loanType,loanAmount,loanState);

alter table loan add FOREIGN KEY (loanNumber,name,number,class,academy,major,loanType,loanAmount,loanState)
REFERENCES student(loanNumber,name,number,class,academy,major,loanType,loanAmount,loanState)ON UPDATE CASCADE ON DELETE CASCADE;
以上是我创建的表:
我 在student表中插入了一行数据,我想修改loan表的loanNumber属性但是提示发生了SQLException异常,这是异常信息:Cannot add or update a child row: a foreign key constraint fails,本来我想利用级联属性来达到修改loan表中的属性进而可以自动的修改student表中的属性,但就是有问题,而删除一行loan表的记录可以,但student中对应的记录没删除,请问这是为什么,我不 是已经添加级联属性了嘛?
请各位高手们赐教,谢谢你们的帮助!
搜索更多相关主题的帖子: MYSQl 数据 
2009-08-04 16:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-281558-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.114491 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved