mysql数据库,建表语句在客户端命令行中执行没问题,但是在phpadmin中执行报错,烦死我了,谁快来帮帮我?

uselaiyangwen;createtableteacher(idintauto_incrementprimarykey,index(id),namevarchar(... use laiyangwen;

create table teacher
(
id int auto_increment primary key ,
index (id),
name varchar(250),
pwd varchar(250)
)type=innodb ;
insert into teacher values(0,'admin','123');
create table grade
(
id int auto_increment primary key,
index (id),
gradeName varchar(250)
)type=innodb ;
insert into grade values(0,'一年级');
insert into grade values(0,'二年级');

create table stuclass
(
id int auto_increment primary key,
index (id),
className varchar(250)
)type=innodb ;
insert into stuclass values(0,'001');
insert into stuclass values(0,'002');

create table student
(
id int auto_increment primary key,
index (id),
gradeId int,
index (gradeId),
foreign key (gradeId) references grade(id) on delete cascade,
classId int,
index(classId),
foreign key (classId) references stuclass(id) on delete cascade,
name varchar(250),
sex varchar(250),
age int,
pwd varchar(250)
)type=innodb ;
insert into student values(0,1,1,'张三11','男',18,'123');
insert into student values(0,1,1,'李四11','男',19,'123');
insert into student values(0,1,1,'王五12','男',18,'123');

create table question
(
id int auto_increment primary key,
index (id),
`type` varchar(250),
kemu varchar(250),
question varchar(250),
A varchar(250),
B varchar(250),
C varchar(250),
D varchar(250),
answer varchar(250),
nandu varchar(250)
)type=innodb ;
create table paper
(
id int auto_increment primary key,
index (id),
paperName varchar(250),
questionId int,
index(questionId),
foreign key (questionId) references question(id) on delete cascade,
createTime datetime,
paperAuthor int ,
index(paperAuthor),
foreign key (paperAuthor) references teacher(id) on delete cascade

)type=innodb ;

create table exam
(
id int auto_increment primary key,
index (id),
paperName varchar(250),
gradeId int,
index(gradeId),
foreign key (gradeId) references Grade(id) on delete cascade,
stuclassId int,
index(stuclassId),
foreign key (stuclassId) references Stuclass(id) on delete cascade,
flag varchar(250),
createTime datetime
)type=innodb ;

create table examRecord
(
id int auto_increment primary key,
index (id),
examId int,
index(examId),
foreign key (examId) references exam(id) on delete cascade,
stuId int,
index (stuId),
foreign key (stuId) references student(id) ,
questionId int,
index(questionId),
foreign key (questionId) references question(id) on delete cascade,
answer varchar(250),
score int ,
isTrue varchar(250),
remark varchar(250),
createTime datetime
)type=innodb ;
展开
 我来答
若以下回答无法解决问题,邀请你更新回答
vistaorg
2012-06-05 · 超过20用户采纳过TA的回答
知道答主
回答量:169
采纳率:0%
帮助的人:54.2万
展开全部
一段内容试试。不要一下都帖进去,或者用客户端的软件试试
追问
是外键的问题  执行到 exam表就出错了,能不能帮我看看,也许是mysql版本问题,5.5的没错,但是服务器上的却报错》。。。。。
追答
foreign key (stuclassId) references Stuclass(id) on delete cascade,	
这个表存在吗?
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式