실험 5 보기 의 정의,사용 실험
2709 단어 데이터 뱅 크
-- 1. “IS” V_IS ;
create view V_IS as
select * from student
where sdept='IS'
with check option ;
/*
drop view v_IS;
create view V_IS as
select * from student
where sdept='IS';
*/
-- select *from v_IS;
-- 2. S,C,SC , , , , V_S_C_G ;
-- drop view V_S_C_G;
create view V_S_C_G as
select sno,sname,cno,cname,grade
from sc join student using(sno)
join course using(cno);
SELECT *from v_s_c_g;
-- 3. , V_NUM_AVG ;
create VIEW V_NUM_AVG as
select Sdept,count(sno) from student
group by sdept;
SELECT * from v_num_avg;
-- 4. V_YEAR ;
create view V_YEAR as
select sno,year(now())-sage as Birthyear
from student;
select *from v_year;
-- 5. V_AVG_S_G ;
-- drop view V_AVG_S_G;
create view V_AVG_S_G as
select sno,count(cno),avg(grade) as avg_grade
from sc join student using(sno)
group by sno;
SELECT * from v_avg_S_G;
-- 6. V_AVG_C_G ;
create view V_AVG_C_G as
select cno,count(*) as cnum,avg(grade) avg_grade
from sc group by cno;
select *from V_AVG_C_G;
-- 7. 90 、 ;
SELECT sno,sname,avg_grade from v_avg_S_G
join student using(sno)
where avg_grade>=90 ;
-- 8. 、 、 ;
SELECT sno,sname,cno,grade from sc a
join student using(sno)
where not exists (
select * from sc b join v_avg_c_g using(cno)
where a.Grade< v_avg_c_g.avg_grade and a.Cno=b.Cno
);
-- 9. 80 , ;
select sdept,count(*) num
from student join v_avg_s_g using(sno)
where avg_grade > 80
group by sdept
order by num desc;
-- 10. V_IS, “200215121” “200215124” “S1_MMM”,”S4_MMM” ;
update V_IS set sno='S1_MMM' where sno='200215121'; -- CS ,
update V_IS set sno='S4_MMM' where sno='200215124';
select *from v_is;
select *from student;
select *from sc;
select *from v_s_c_g;
-- 11. V_IS, ('S12','YAN XI',19,'IS'), ;
insert into V_IS(sno,sname,sage,sdept) values('S12','YAN XI',19,'IS');
-- 12. V_IS, ('S13','YAN XI',19,'MA'), ;
-- MA , check .
insert into v_is(sno,sname,sage,sdept) values('S13','YAN XI',19,'MA');
-- 13. V_IS, “S12” “S13” , ;
-- s13 is ,
delete from v_is where sno='S12' or sno='S13' ;
-- 14. V_S_C_G, “200215124” “200215124_MMM”, ?
update v_s_c_g set sname='200215124_MMM' where sno='200215124';
-- 15. V_AVG_S_G, “S1” 90 , ?
-- , , ,
-- , ,
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
nginx websocket ip_해시 규칙프로젝트 를 다운로드 한 후 서로 다른 네트워크 에 각각 이 demo 프로젝트 를 배치 합 니 다. 프로젝트 에서 환경 변수 에 따라 시스템 변 수 를 설정 합 니 다. spring.profiles.active=de...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.