测试一参考答案
1.建表与插入数据
create database School;
use School;
create table Classes (
cid int primary key,
cname varchar(30),
cteacher varchar(10)
);
create table Student (
sid int primary key,
sname varchar(10),
ssex char(2),
sage smallint,
sclass int,
foreign key (sclass)
references Classes (cid)
);
insert into Classes values( 1,'2010级软件工程1班','张老师');
insert into Classes values( 2,'2010级软件工程2班','张老师');
insert into Classes values( 3,'2010级计算机科学与技术1班','王老师');
insert into Classes values( 4,'2010级计算机科学与技术2班','王老师');
insert Into Student(sid,sname,sage,ssex,sclass) values(1,'张三',19,'男',3);
insert Into Student(sid,sname,sage,ssex,sclass) values(2,'李四',20,'男',4);
insert Into Student(sid,sname,sage,ssex,sclass) values(3,'王五',18,'女',3);
insert Into Student(sid,sname,sage,sse