1.
张表,学生表 S,课程 C,学生课程表 SC,学生可以选修多门课程,一门课程可以被各种学生选
修,通 过 SC 表关联;(SQL)
1)
写出建表语句;
答:建表语句如下(mysql
数据库):
create table s(id integer primary key,name varchar(20));
create table c(id integer primary key,name varchar(20));
create table sc(
sid integer references s(id),
cid integer references c(id),
primary key(sid,cid)
);
2)
写 出 SQL 语句,查询选修了所有选修课程学生;
答:SQL 语句如下:
select stu.id,stu.name from s stu
where (select count(*) from sc where sid=stu.id) =
(select count(*) from c);
3)
写 出 SQL 语句,查询选修了至少 5 门以上课程学生。
答:SQL 语句如下:
select stu.id,stu.name from s stu
where (select count(*) from sc where sid=stu.id)>=5;
2.
数据库表(Test)构造如下:(SQL)
IDNAMEAGEMANAGER(所属主管人 ID)
106A30104
109B19104
104C1
评论0
最新资源