




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、集團文件版本號:(M928-T898-M248-WU2669-I2896-DQ586-M1988)實驗名稱:SQL數(shù)據(jù)查詢一、實驗?zāi)康模簲?shù)據(jù)查詢語句是SQL語句的重要組成部分,合理使用數(shù)據(jù)查詢語句,可以極大的 簡化應(yīng)用程丿宇編制、快速的定位分析數(shù)據(jù)庫系統(tǒng)的故障,查詢語句是編程人員與數(shù)據(jù) 庫管理人員必不可少的工具,通過實驗達到以下目的:(1)加深學(xué)生對查詢語句基本概念的理解與學(xué)握,最終達到靈活應(yīng)用。(2)掌握SELECT語句的基本語法。(3)常握簡單單表查詢、連接查詢、嵌套查詢。(4)學(xué)會使用聚函數(shù)和進行分組查詢。二、實驗內(nèi)容:1、單表查詢:2、連接查詢3、嵌套查詢?nèi)嶒灜h(huán)境Windows x
2、p 系統(tǒng) SQL Server2000 服務(wù)器四、程序源碼與運行結(jié)果1、單表查詢:設(shè)計查詢語句完成對 *、distinct、like (%和_)、in、not in、betweenand、order by、group by 等的應(yīng)用。(1)檢索出學(xué)生信息表中所有女生的記錄。Select * from student where sex二女(2)從選課成績表中檢索出所有學(xué)生的成績,并去除重復(fù)值。select distinct grade from cs(3)從課程表中檢索出全部數(shù)據(jù)的信息。select * from course where cname like 數(shù)據(jù)(3)從學(xué)生信息表中檢索出姓
3、王的學(xué)生的信息。select * from student where sname like 王_(4)從成績表中找出成績等于60分的學(xué)生的性別。6. 查詢年齡在2023歲的學(xué)生信息(要求至少使用兩種方式完成查詢)select * from student where age between 20 and 23 (第一種) select * from student where (age=20 and age=23) (第二種)7. 使用IN關(guān)鍵字查詢信息系(IS)、數(shù)學(xué)系(MA)和計算機科學(xué)系(CS)的 學(xué)生select * from studentwhere sno in (select
4、sno from student where dept二IS)select * from studentwhere sno in (select sno from student where dept二MA)select * from studentwhere sno in (select sno from student where dept二CS)8. 查詢既不是信息系、數(shù)學(xué)系,也不是計算機科學(xué)系的學(xué)生的姓名和性別。 select sname, sex from studentwhere dept !二MAand dept!二CSand dept!二TS9. 查詢所有姓劉學(xué)生的姓名、學(xué)號和
5、性別。select sname, sno, sex from student where sname like ,文10. 查詢名字中第2個字為邙日字的學(xué)生的姓名和學(xué)號。select sname, sno from student where sname like 陽11. 查詢DB_Design課程的課程號和學(xué)分(先在Course表中插入DB_Design” 課程信息)。select cname, score from course where cname二DB_Design12. 查詢沒有考試成績的學(xué)生學(xué)號和課程號。13. 查詢計算機系年齡在20歲以下的學(xué)生姓名。select sname
6、from student where age=321、查詢有3門以上課程是90分以上的學(xué)生的學(xué)號及(90分以上的)課程數(shù)。select sno,count (eno) from cs where grade=90group by sno having count (eno)=322、查詢?nèi)w學(xué)生與選課表的笛卡爾積。23、查詢每個學(xué)生及其選修課程的情況。select distinct * from student cross join cs where student snores sno24、查詢每個學(xué)生及其選修課程的情況(去掉重復(fù)屬性)select a. sno, sname, sex, d
7、ept, age, b eno, cname, score, c. gradefrom student a, course b, cs c where a.sno二c sno and b cno=c eno25、查詢某門課程考試成績相同的學(xué)生學(xué)號和課程信息select a. sno, b eno, b cname, b score from cs a, course bwhere a. cno=beno and (select count(*) from cs where eno二eno and grade=grade)二226、查詢每個學(xué)生的選修課程包括沒有選修課程的學(xué)生(外連接)selec
8、t * from student a, cs b where a.sno*二b sno27、查詢每個學(xué)生的選修課程包括沒有被學(xué)生選修的課程(外連接)select * from student ,cs where student sno =*cs sno28、查詢每個學(xué)生的選修課程即包括沒有被學(xué)生選修的課程又包括沒有被學(xué)生選修的 課程(全連接)select * from student full join cs on student sno二cs sno29、查詢選修2號課程且成績在90分以上的所有學(xué)生的學(xué)號、姓名select sno, sname from studentwhere sno i
9、n(select sno from cs where grade二90and cno=,C002,)30、查詢每個學(xué)生的學(xué)號、姓名、選修的課程名及成績select student. sno, sname, cname, grade from student, course,cswhere (student sno二cs sno) and (course cno=cs eno)31、查詢與“張三”在一個系學(xué)習(xí)的學(xué)生(IN)where dept in(select dept from student where sname二弓長三)32、查詢選修了課程名為“信息系統(tǒng)”的學(xué)生學(xué)號和姓名。select sno, sname from studentwhere sno in (select sno from cs where eno in(select eno from course wherecname二信息系統(tǒng))33、查詢與“張三”在同一個系學(xué)習(xí)的學(xué)生select * from studentwhere dept in (select dept from student where sname張三)34、查詢選修了課程1或者選修了課程2的學(xué)生(要求消除重復(fù)組UNION)(selectsnofromcswherecno=,C001,)UNION(selectsnofro
溫馨提示
- 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)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 五年級數(shù)學(xué)下冊教案《確定位置(一)》北師大版
- 《百分數(shù)-百分數(shù)的認識》教學(xué)設(shè)計-2024-2025學(xué)年六年級上冊數(shù)學(xué)北師大版
- 蘇教版三年級上冊期中考試數(shù)學(xué)試卷-(含解析)
- 2025年廣西電力職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫1套
- 2025年貴州電子信息職業(yè)技術(shù)學(xué)院單招職業(yè)適應(yīng)性測試題庫審定版
- Unit1 Making friends (教學(xué)設(shè)計)-2024-2025學(xué)年人教PEP版(2024)英語三年級上冊
- 2024年全息投影項目資金籌措計劃書代可行性研究報告
- 2025年廣西機電職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫附答案
- 2024年飼用天然有效成分制劑項目資金籌措計劃書
- 第二章 有理數(shù)及其運算單元教學(xué)設(shè)計 -2024-2025學(xué)年魯教版(五四制)數(shù)學(xué)六年級上冊
- 山東大學(xué)出版社六年級上冊傳統(tǒng)文化第一單元寬仁厚愛備課教案
- 2023年金華職業(yè)技術(shù)學(xué)院高職單招(英語)試題庫含答案解析
- GB/T 16492-1996光學(xué)和光學(xué)儀器環(huán)境要求總則、定義、氣候帶及其參數(shù)
- 部編版四年級語文下冊第二單元教案
- FZ/T 01010-2012涂層織物涂層剝離強力的測定
- 混凝土耐久性課件
- 情報學(xué)與情報分析基礎(chǔ)知識課件
- 窮查理寶典課件
- 殯葬禮儀服務(wù)整體保障方案
- 中山市口腔醫(yī)院門診牙科診所醫(yī)療機構(gòu)地址名單
- 新疆特色美食介紹課件
評論
0/150
提交評論