现在有以下三张表,请回答下面问题
Student(S#,SN,SD)学生表
Course(C#,CN,T#)课程表
SC(S#,C#,score)成绩表
1.使用嵌套查询的方式查询选了课程‘税收基础’的学生的学号和名字
答:
select SN,SD from Student where S# in(
select S# from Course C , SC where C.C#=SC.C# and CN=’税收基础’);
2.使用嵌套查询选课数量大于5的学生的学号和名字
答:
select SN,SD from Student where S# in (
select S# from SC group by S# having count(distinct C#) > 5);
)
3.建立一个学生表students,包括name,age,head_teacher,id,score(姓名,年龄,班主任,学号,成绩)
Create table students(
Id number(9) not null primary key,
Name varchar2(40) not null,
Age int check(age between 0 and 100),
Head_teacher vachar2(40),
Score float
);
4.对上表插入一条记录,姓名:张三,年龄:18,班主任:李四,学号:22
Insert into student(id,name,age,head_teacher) values(‘22’,’张三’,’18’,’李四’);
5.对上表中的age+name创建一个索引,并说明它的作用和使用方法
Create index student_index on students(age,name);