2016030207 - sql50题练习(脚本)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2016030207 - sql50题练习(脚本)相关的知识,希望对你有一定的参考价值。
我的mysql版本是5.下面sql练习题的前提脚本代码。
-- Student(S#,Sname,Sage,Ssex) 学生表 -- Course(C#,Cname,T#) 课程表 -- SC(S#,C#,score) 成绩表 -- Teacher(T#,Tname) 教师表 create table student ( sid int(4) not null primary key auto_increment, sname char(20) not null, sage int(3) not null, ssex int(1) not null default ‘1‘ ); create table course( cid int(4) not null primary key auto_increment, cname char(50) not null, tid int(4) not null ); create table sc( sid int(4) not null, cid int(4) not null, score int(3) not null ); create table teacher( tid int(4) not null primary key auto_increment, tname char(20) not null ); insert into student values(1,‘Tom‘,25,1), (2,‘Joan‘,19,0), (3,‘Wang‘, 41,1), (4,‘lucy‘, 52,0), (5,‘lili‘, 61,1); insert into teacher values(1,‘Liming‘), (2,‘Wangshan‘), (3,‘Zhangheng‘), (4, ‘Hushi‘); insert into course values (1,‘java‘, 2), (2,‘think‘,3), (3,‘math‘,1),(4,‘Chinese‘, 1), (5,‘high math‘,2); insert into sc values (1,1,24),(1,2,60),(1,3,70),(1,4,90),(1,5,99); insert into sc values (2,1,60),(2,2,80),(2,3,60),(2,4,91),(2,5,89); insert into sc values (3,1,66),(3,2,78),(3,3,90),(3,4,78),(3,5,90); insert into sc values (4,1,80),(4,2,34),(4,3,81),(4,4,56),(4,5,90); insert into sc values (5,1,99),(5,2,32),(5,3,45),(5,4,12),(5,5,76);
以上是关于2016030207 - sql50题练习(脚本)的主要内容,如果未能解决你的问题,请参考以下文章