学生表Student(Sno,Sname,Ssex,Snation,Spolitical,Sbirth,Scollege,Smajor,Sclass)
课程表Course (Cno,Cname,Credit,Cproperty,Chour,Cterm)
选课表SC(Sno,Cno,Grade)
教师表Teacher(Tno,Tname,Tsex,Tbirth,Ttitle,Tcollege)
授课表TC(Id,Tno,Cno,Sclass,Semester,TimePlace)
供应商表s(sno, sname, city)
零件表p(pno, pname, color, weight)
工程项目表j(jno, jname, city)
供应情况表 spj(sno, pno, jno, qty)
delete
from sc
where sno in
(select sno
from student
where sname = '刘家顺'
);
delete
from student
where sname = '刘家顺';
commit;
update student
set smajor = '计算机科学与技术', sclass = '计算机1班'
where sno = '103465';
commit;
delete
from sc
where sno in
(select sno
from sc
where grade < 60 and cno in
(select cno
from course
where cname = '嵌入式系统与应用'
)
);
commit;
insert
into teacher
values('1203076','吕振华','男',to_date('1985/11/8','yyyy/mm/dd'),'讲师','体育部');
commit;
课程号:3094217,课程名:图与网络,课程学分:2,课程性质:选修,课程学时:32,开课学期:6
课程号:3094215,课程名:智能搜索与推荐技术,课程学分:2,课程性质:选修,课程学时:32,开课学期:7
insert all
into course values('3094217','图与网络',2,'选修',32,6)
into course values('3094215','智能搜索与推荐技术',2,'选修',32,7)
select 1 from dual;
commit;
create or replace view xg_view
as
select tname, ttitle, cname, sclass, semester
from teacher, tc, course
where teacher.tno = tc.tno and course.cno = tc.cno;
create or replace view xf_view
as
select student.sno, sname, sum(credit) as SumCredit
from student
left join sc on sc.sno = student.sno
left join course on course.cno = sc.cno
group by student.sno, sname;
select *
from xf_view
where sno in
(select sno
from student
where sclass = '大数据2班'
);
insert
into s
values('s9','英特尔','西安');
insert all
into spj values('s9','p5','j7',600)
into spj values('s9','p4','j4',500)
select 1 from dual;
commit;
update spj
set qty = qty + 150
where sno in
(select spj.sno
from spj, s
where spj.sno = s.sno and city = '北京'
);
update p
set color = '黑'
where pno in
(select pno
from p
where color = '红'
);
update spj
set sno = 's1'
where sno in
(select sno
from spj
where jno = 'j4' and pno = 'p6' and sno = 's5'
);
commit;
insert
into spj
values('s2', 'p4', 'j7', 510);
commit;
delete
from spj
where pno = 'p1';
delete
from p
where pno = 'p1';
commit;
create or replace view sd_view
as
select sname, pname, weight, jno, qty
from s, p, spj
where s.sno = spj.sno and p.pno = spj.pno;
select sname
from sd_view
where qty between 400 and 600;
create or replace view sj_view
as
select sno, pno, qty
from spj
where jno in
(select jno
from j
where jname = '三建'
);
最近刚学数据库操作,如果有错误或者哪里还有不足,希望大佬可以指出。