sql练习-S-C-SC建表
use selectpractice; drop table if exists SC; create table SC( sno varchar(200), cno varchar(200), scgrade varchar(200) ); drop table if exists S; create table S( sno varchar(200), sname varchar(200) ); drop table if exists C; create table C( cno varchar(200), cname varchar(200), cteacher varchar(200) ); insert into C(cno, cname, cteacher) value('1', '语文', '张'); insert into C(cno, cname, cteacher) value('2', '政治', '王'); insert into C(cno, cname, cteacher) value('3', '英语', '李'); insert into C(cno, cname, cteacher) value('4', '数学', '赵'); insert into C(cno, cname, cteacher) value('5', '物理', '周'); commit; insert into S(sno, sname) values('1', '学生1'); insert into S(sno, sname) values('2', '学生2'); insert into S(sno, sname) values('3', '学生3'); insert into S(sno, sname) values('4', '学生4'); commit; insert into SC(sno, cno, scgrade) values('1', '1', '40'); insert into SC(sno, cno, scgrade) values('1', '2', '30'); insert into SC(sno, cno, scgrade) values('1', '3', '20'); insert into SC(sno, cno, scgrade) values('1', '4', '80'); insert into SC(sno, cno, scgrade) values('1', '5', '60'); insert into SC(sno, cno, scgrade) values('2', '1', '60'); insert into SC(sno, cno, scgrade) values('2', '2', '60'); insert into SC(sno, cno, scgrade) values('2', '3', '60'); insert into SC(sno, cno, scgrade) values('2', '4', '60'); insert into SC(sno, cno, scgrade) values('2', '5', '60'); insert into SC(sno, cno, scgrade) values('3', '1', '60'); insert into SC(sno, cno, scgrade) values('3', '3', '80'); commit;