ͼ5-9
(3) ²éѯ¡°´óѧ¼ÆËã»ú»ù´¡¡±¿Î³Ì¿¼ÊԳɼ¨Ç°ÈýÃûµÄѧÉúÐÕÃûºÍ³É¼¨¡£ select st_info.st_id,st_name,score from st_info
inner join s_c_info on st_info.st_id=s_c_info.st_id inner join c_info on s_c_info.c_no=c_info.c_no and c_name='´óѧ¼ÆËã»ú»ù´¡'
ͼ5-10
(4) ½«s_c_infoÖеÄscoreÁеÄֵתΪµÈ¼¶ÖÆÊä³ö£¬¼´60·ÖÒÔÏÂÏÔʾΪ¡°²»¼°¸ñ¡±£¬60~69·ÖÏÔʾ¡°¼°¸ñ¡±£¬70~79·ÖÏÔʾ¡°Öеȡ±£¬80~81ÏÔʾ¡°Á¼ºÃ¡±£¬90~100ÏÔʾ¡°ÓÅÐ㡱¡£ÒªÇóÊä³öѧºÅ¡¢ÐÕÃû¡¢¿Î³ÌÃû¡¢³É¼¨µÈ¼¶¡£(Ìáʾ£º
6 / 13
ÔÚselect×Ö¾äÖÐʹÓÃcase¡when¡endÓï¾ä) select st_info.st_id,st_name,c_name,³É¼¨µÈ¼¶= case
when score>=90 then'ÓÅÐã' when score>=80 then'Á¼ºÃ' when score>=70 then'ÖеÈ' when score>=60 then'¼°¸ñ' when score<60 then'²»¼°¸ñ' end
from s_c_info,st_info,c_info
where st_info.st_id=s_c_info.st_id and c_info.c_no=s_c_info.c_no
ͼ5-11
(¶þ)SQLµÄÔöɾ¸Ä¹¦ÄÜ
ÔÚʵÑéËĽ¨Á¢µÄstudbÊý¾Ý¿âÖУ¬Ð´SQLÓï¾äʵÏÖÔöɾ¸Ä¹¦ÄÜ¡£ 1£®ÔÚS±íÖÐÔö¼ÓÈçϼǼ£º
ͼ5-12
7 / 13
insert S
values('s3','ÕÅÃ÷»ª','ÄÐ','1995/08/21 00:00:00.000','MA_Êýѧ','530.0','Õ㽺¼ÖÝ',NULL)
ͼ5-13
ͼ5-14
2. ÔÚC±íÖн«¿Î³ÌÃûΪ¡°Êý¾Ý¿â¡±µÄѧ·Ö¸ü¸ÄΪ3¡£ update C set ccredit='3' where cname='Êý¾Ý¿â'
ͼ5-15
ͼ5-16
3£®É¾³ýS±íÖÐS2µÄѧÉú¼Ç¼£¬ÇëÎÊÊÇ·ñÄÜɾ³ý£¬ÎªÊ²Ã´£¬ÒªÈçºÎ²Ù×÷¡£ ÄÜɾ³ý
delete from S where sno='S2'
8 / 13
ͼ5-17
ͼ5-18
ͼ5-19
ͼ5-20
(Èý)Ë÷Òý
1.ÔÚstudbÊý¾Ý¿âÖУ¬·Ö±ðÓöÔÏó×ÊÔ´¹ÜÀíÆ÷ºÍSQLÓïÑÔ¶¨ÒåË÷Òý
ÔÚ¶ÔÏó×ÊÔ´¹ÜÀíÆ÷ÖУ¬ÔÚT±íµÄtnameÁÐÉÏÖн¨Á¢¾Û¼¯Ë÷Òýix_tname£¬½µÐò¡£²é¿´
9 / 13
¾Û¼¯µÄЧ¹û¡£
ͼ5-21
ͼ5-22
1£®Ê¹ÓÃSQLÓïÑÔ¶¨ÒåTC±íµÄ(tno£¬cno)ÁÐÉϵĸ´ºÏË÷Òýix_tc£¬tnoÁÐÉèΪÉýÐò£¬cnoÁÐÉèΪ½µÐò
ÏÈÔö¼ÓcnoÁУ¬ÔÙɾ³ý¾Û¼¯Ë÷Òýix_tname¡£ create clustered index ix_tc
10 / 13