高分向高手急求数据库问题的解答

来源:百度知道 编辑:UC知道 时间:2024/09/24 09:04:16
有如下三个表:学生表(student),课程表(course),选课表(SC),写出一下8个SQL语句
Student(学号Sname,姓名Sname,年龄Sage,所在系Sdept)
Course(课程号Cno,课程名Cname,先行课Cpno,学分Ccredit)
SC(学号Sno, 课程号Cno, 成绩Grade)

1 建立如上“学生”表Student,学号是主码,姓名取值唯一。
2查询所有年龄在20岁一下的学生姓名及其年龄。
3查询姓“欧阳”且全名为三个汉字的学生的姓名。
4 查询学生200215012选修课程的总学分数。
5 查询选修2号课程切成绩在90分以上的所有学生
6 查询其他系中比计算机科学系(CS)所有学生年龄都小的学生姓名及年龄.
7 将一个新学生元组(学号:200215128;姓名:陈冬;性别:男;所在系:IS;年龄:18岁)插入到Student表中
8 将学生200215121的年龄改为22岁.

你是问CS问题?
SQL我知道注入
你这是写程序啊?

1 建立如上“学生”表Student,学号是主码,姓名取值唯一。 create table student
(
Sid bigint identity(1,1) primary key not null,
Sname nvarchar(50) not null,
Sage nvarchar(50) not null,
constraint detp_id foreign key references SC(dept_id) not null,外键

)
2查询所有年龄在20岁一下的学生姓名及其年龄。 select Sname,Sage from student where Sage<20
3查询姓“欧阳”且全名为三个汉字的学生的姓名。 select Sname from student where Sname='欧阳_'
4 查询学生200215012选修课程的总学分数。 select sum(Grade) from SC where Sno=200215012
5 查询选修2号课程切成绩在90分以上的所有学生 select * from student where 学号=(select Sno from SC where Grade>90 and Cno=2)
6 查询其他系中比计算机科学系(CS)所有学生年龄都小的学生姓名及年龄. select Sname,Sage from student where Sdept!='CS' and Sage<(select min(Sage) from student where Sdept='CS')
7 将一个新学生元组(学号:200215128;姓名:陈冬;性别:男;所在系:IS;年龄:18岁)插入到Student表中
insert into student(学号,Sname,性别,Sdept,Sage) values(200215128,'陈冬','男','IS