




全文預(yù)覽已結(jié)束
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
實驗五 數(shù)據(jù)庫綜合查詢一、實驗?zāi)康?. 掌握SELECT語句的基本語法和查詢條件表示方法;2. 掌握查詢條件種類和表示方法;3. 掌握連接查詢的表示及使用;4. 掌握嵌套查詢的表示及使用;5. 了解集合查詢的表示及使用。二、實驗內(nèi)容1. 了解SELECT語句的基本語法格式和執(zhí)行方法;2. 以數(shù)據(jù)庫原理實驗5數(shù)據(jù)為基礎(chǔ),請使用T-SQL 語句實現(xiàn)進行相應(yīng)操作;3. 完成實驗報告。三、實驗步驟1. 查詢以數(shù)據(jù)_開頭,且倒數(shù)第3個字符為結(jié)的課程的詳細情況 select*from coursewhere Cname like 數(shù)據(jù)_%結(jié)_escape2. 查詢名字中第2個字為陽的學(xué)生姓名和學(xué)號及選修的課程號、課程名; select sname 姓名,student.sno 學(xué)號,o 課程號,ame 課程名from student,course,sc where student.sno=sc.sno and o=o and sname like_陽%3. 列出選修了數(shù)學(xué)或者大學(xué)英語的學(xué)生學(xué)號、姓名、所在院系、選修課程號及成績; select student.sno,sname,sdept,cno,gradefrom student,scwhere student.sno=sc.sno and cno IN(select cno from course where cname=數(shù)學(xué)OR CNAME=大學(xué)英語)4. 查詢?nèi)鄙俪煽兊乃袑W(xué)生的詳細情況; select*from student where not exists(select*from sc where sno=student.sno and grade is not null)select*from student where sno in(select sno from sc where grade is null)5. 查詢與張力(假設(shè)姓名唯一)年齡不同的所有學(xué)生的信息; select b.*from student a,student b where a.sname=張力and a.sageb.sage6. 查詢所選課程的平均成績大于張力的平均成績的學(xué)生學(xué)號、姓名及平均成績; select student.sno,sname,平均成績=avg(grade)from student,sc where sc.sno=student.sno group by student.sno,sname having avg(grade)(select avg(grade)from sc where sno=(select sno from student where sname=張力)7. 按照“學(xué)號,姓名,所在院系,已修學(xué)分”的順序列出學(xué)生學(xué)分的獲得情況。其中已修學(xué)分為考試已經(jīng)及格的課程學(xué)分之和; select student.sno 學(xué)號,sname 姓名,sdept 院系,已修學(xué)分=sum(credit)from student,course,sc where student.sno=sc.sno and o=o and grade=60 group by student.sno,sname,sdept8. 列出只選修一門課程的學(xué)生的學(xué)號、姓名、院系及成績; select student.sno 學(xué)號,sname 姓名,sdept 院系,gradefrom student,sc where student.sno=sc.sno and sc.sno in(select sno from sc group by sno having count(cno)=1)9. 查找選修了至少一門和張力選修課程一樣的學(xué)生的學(xué)號、姓名及課程號; select distinct student.*from student where sno in(select sno from sc where cno in(select cno from course where cname=數(shù)據(jù)庫or cname=數(shù)據(jù)結(jié)構(gòu))10. 只選修“數(shù)據(jù)庫”和“數(shù)據(jù)結(jié)構(gòu)”兩門課程的學(xué)生的基本信息; select o,ame,x.sno,x.sname,grade from student x,sc y,course z where x.sno=y.sno and o=o11. 至少選修“數(shù)據(jù)庫”或“數(shù)據(jù)結(jié)構(gòu)”課程的學(xué)生的基本信息;select *from student,sc,coursewhere student.sno=sc.snoand o=oand cname=數(shù)據(jù)庫orcname=數(shù)據(jù)結(jié)構(gòu)12. 列出所有課程被選修的詳細情況,包括課程號、課程名、學(xué)號、姓名及成績; select o,ame,student.sno,student.sname,gradefrom student,sc,coursewhere student.sno=oand o=o13. 查詢只被一名學(xué)生選修的課程的課程號、課程名; select cno,cnamefrom coursewhere cno in(select cnofrom scgroup by cnohaving count(sno)=1)14. 使用嵌套查詢列出選修了“數(shù)據(jù)結(jié)構(gòu)”課程的學(xué)生學(xué)號和姓名; select sno,snamefrom studentwhere sno in(select snofrom scwhere cno in(select cnofrom coursewhere cname=數(shù)據(jù)結(jié)構(gòu))15. 使用嵌套查詢查詢其它系中年齡小于CS系的某個學(xué)生的學(xué)生姓名、年齡和院系; select sname,sage,sdeptfrom studentwhere sage(select max(sage)from studentwhere sdept=csand sdeptcs)16. 使用ANY、ALL 查詢,列出其他院系中比CS系所有學(xué)生年齡小的學(xué)生; select sname,sagefrom studentwhere sageany(select min(sage)from studentwhere sdept=csand sdeptcs)select sname,sagefrom studentwhere sageall(select sagefrom studentwhere sdept=csand sdeptcs)17. 分別使用連接查詢和嵌套查詢,列出與張力在一個院系的學(xué)生的信息; select*from studentwhere sdept=(select sdeptfrom studentwhere sname=張力)18. 使用集合查詢列出CS系的學(xué)生以及性別為女的學(xué)生名單; select snamefrom studentwhere sdept=csunionselect snamefrom studentwhere ssex=女19. 使用集合查詢列出CS系的學(xué)生與年齡不大于19歲的學(xué)生的交集、差集; select*from stu
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 新品轉(zhuǎn)量產(chǎn)流程標準化體系
- 法國職業(yè)教育體系解析
- 2025年康復(fù)醫(yī)療器械市場創(chuàng)新產(chǎn)品應(yīng)用趨勢與需求研究報告
- 養(yǎng)老服務(wù)中心設(shè)施設(shè)計評估報告:智能化養(yǎng)老護理服務(wù)培訓(xùn)體系2025
- 高校產(chǎn)學(xué)研一體化協(xié)同創(chuàng)新生態(tài)構(gòu)建與2025年發(fā)展態(tài)勢評估報告
- 工銀商戶培訓(xùn)
- 2025年環(huán)境監(jiān)測智能化發(fā)展趨勢與數(shù)據(jù)質(zhì)量優(yōu)化策略分析報告
- 下肢運動培訓(xùn)課件
- 管理創(chuàng)新知識培訓(xùn)
- 河道采砂作業(yè)安全培訓(xùn)
- 酒店升級改造方案
- 高一新生分班考試英語試卷(含答案)
- 軍工行業(yè)產(chǎn)業(yè)分析
- 《地震和地震災(zāi)害》課件
- 《古典主義文學(xué)》課件
- 腎病科膜增生性腎小球腎炎診療規(guī)范2023版
- 人工智能引論智慧樹知到課后章節(jié)答案2023年下浙江大學(xué)
- 衛(wèi)浴行業(yè)和水龍頭知識培訓(xùn)教材課件
- 裝飾工程項目管理組織機構(gòu)
- 金庫安全門采購合同范本
- 公路橋位勘測設(shè)計規(guī)范
評論
0/150
提交評論