1、创建SC表必须先确定创建好STUDENT表,因为STUDENT表中的SNO字段为SC表中的SNO的foreign key(我是这么设计的,因为如果学生表中都没有这个学生,怎么会有学生选课中的数据)。
create table sc (cno varchar(8) primary key,sno varchar(8),constraint SC_SNO_FK foreign key(sno) references student(sno),grade number(8))
2、select a.sno,a.sname,a.ssex from student a,course b,sc c where a.sno=c.sno and b.cno=c.cno and b.ccredit=5 and c.grade>60
3、有点模糊不清楚,学分是指course表中的那个学分,还是包括sc表中的grade。
4、如果成绩指的是SC表的数据。
update sc set grade='75' where sno=(select sno from student where sname='李立') and cno=(select cno from course where cname='数据库')
5、先修课和课程号 什么概念。说实话有点乱。
6、select b.cname from student a,course b,sc c where a.sno=c.sno and b.cno=c.cno and a.sname='李小波'
7、
select sname,sdept from student t1,
(select a.same s1,min(c.grade) s2
from student a,course b,sc c
where a.sno=c.sno
and b.cno=c.cno
group by a.sname
having min(c.grade)>80) t2
where t2.s1=t1.sname
8、select a.aname,c1.grade 英语分数,c2.grade 数据分数 from student a,course b1,course b2, sc c1 ,sc c2 where a.sno=c1.sno and a.sno=c2.sno and c1.grade>c2.grade and b1.cname='英语' and b1.cno=c1.cno and b2.cno=c2.cno and c2.name='数学'
9、create view test as select a.sno,a.name,count(c.cno) 选课门数 from students a,course b,sc c where a.sno=c.sno and b.cno=c.cno group by a.sno,a.name 少些一个补考门数。实在不会了。请教高人。
10、这是查找学生李丽,都选了那些课吗?
select b.cname from student a,course b,sc c from where a.sno=c.sno and b.cno=c.cno and a.sname like '%李丽%'
就这些吧。。第四题自己想去吧。
create or replace package pk2 isprocedure jobs(empid scott.emp.job%type,numbs out number)
function depts(deptid scott.emp.deptno%type) return number
end pk2
/
create or replace package body pk2 is
procedure jobs(empid scott.emp.job%type,numbs out number) is
begin
select count(*)
into numbs
from emp
where job = empid
exception
when others then
numbs := 0
end
function depts(deptid scott.emp.deptno%type) return number is
numbs number
begin
select count(*)
into numbs
from emp
where deptno = deptid
return numbs
exception
when others then
return 0
end
end pk2
/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)