标签:innodb htm teacher mysql 地址 art one 作业 分享
Mysql练习题博客地址:http://www.cnblogs.com/wupeiqi/articles/5729934.html
代码如下:
create table class( cid int not null primary key ,caption char(10))engine=innodb default charset=utf8; insert into class values(1,‘三年二班‘),(2,‘一年三班‘),(3,‘三年一班‘);
create table teacher( tid int not null primary key,tname char(10))engine=innodb default charset=utf8; insert into teacher values(1,‘egon‘),(2,‘alex‘),(3,‘wusir‘);
create table student( sid int not null primary key,sname char(10),gender enum(‘男‘,‘女‘),class_id int not null,constraint fk_sc foreign key (class_id) references class(cid))engine=innodb default charset=utf8; insert into student values(1,‘钢蛋‘,‘女‘,1),(2,‘铁锤‘,‘女‘,1),(3,‘山炮‘,‘男‘,2);
create table course( cid int not null primary key,cname char(10),teacher_id int not null,constraint fk_ct foreign key (teacher_id) references teacher(tid))engine=innodb default charset=utf8; insert into course values(1,‘生物‘,1),(2,‘体育‘,1),(3,‘物理‘,2);
create table score( sid int not null primary key,student_id int not null,course_id int not null,number int not null,constraint fk_ss foreign key (student_id) references student(sid),constraint fk_scadd foreign key (course_id) references course(cid))engine=innodb default charset=utf8; insert into score values(1,1,1,60),(2,1,2,59),(3,2,2,100);
标签:innodb htm teacher mysql 地址 art one 作业 分享
原文地址:http://www.cnblogs.com/lxyoung/p/6946611.html