mysql创建外键错误 erro150语句如下
--创建科目表createtablet_subject(idINTprimarykeynotnullauto_increment,subjectNoVARCHAR(45)...
--创建科目表
create table t_subject(
id INT primary key not null auto_increment,
subjectNo VARCHAR(45),
subjectName VARCHAR(45));
--创建学生版
create table t_student(
id INT primary key not null auto_increment,
No VARCHAR(45),
name VARCHAR(45));
--成绩表
create table t_score(
id INT primary key not null auto_increment,
fraction INT,
t_subjectId INT,
t_studentId INT,
FOREIGN KEY (t_subjectId) REFERENCES t_subject(id),
FOREIGN KEY (t_studentId) REFERENCES t_student(id)
);
创建成绩表的时候出错了erro150 展开
create table t_subject(
id INT primary key not null auto_increment,
subjectNo VARCHAR(45),
subjectName VARCHAR(45));
--创建学生版
create table t_student(
id INT primary key not null auto_increment,
No VARCHAR(45),
name VARCHAR(45));
--成绩表
create table t_score(
id INT primary key not null auto_increment,
fraction INT,
t_subjectId INT,
t_studentId INT,
FOREIGN KEY (t_subjectId) REFERENCES t_subject(id),
FOREIGN KEY (t_studentId) REFERENCES t_student(id)
);
创建成绩表的时候出错了erro150 展开
展开全部
试试:
create table t_score(
id INT primary key not null auto_increment,
fraction INT,
t_subjectId INT,
t_studentId INT,
FOREIGN KEY fk_score_sub (t_subjectId) REFERENCES t_subject(id),
FOREIGN KEY fk_score_sutd (t_studentId) REFERENCES t_student(id)
);
http://www.cnblogs.com/hcbin/archive/2010/03/31/1701086.html
create table t_score(
id INT primary key not null auto_increment,
fraction INT,
t_subjectId INT,
t_studentId INT,
FOREIGN KEY fk_score_sub (t_subjectId) REFERENCES t_subject(id),
FOREIGN KEY fk_score_sutd (t_studentId) REFERENCES t_student(id)
);
http://www.cnblogs.com/hcbin/archive/2010/03/31/1701086.html
追问
Can't create table 'zuoye.t_score' (errno: 150)还是不行哦
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |