九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

SQL數(shù)據(jù)查詢策略

上傳人:z**** 文檔編號(hào):50933115 上傳時(shí)間:2022-01-24 格式:DOC 頁(yè)數(shù):5 大?。?5KB
收藏 版權(quán)申訴 舉報(bào) 下載
SQL數(shù)據(jù)查詢策略_第1頁(yè)
第1頁(yè) / 共5頁(yè)
SQL數(shù)據(jù)查詢策略_第2頁(yè)
第2頁(yè) / 共5頁(yè)
SQL數(shù)據(jù)查詢策略_第3頁(yè)
第3頁(yè) / 共5頁(yè)

本資源只提供3頁(yè)預(yù)覽,全部文檔請(qǐng)下載后查看!喜歡就下載吧,查找使用更方便

10 積分

下載資源

資源描述:

《SQL數(shù)據(jù)查詢策略》由會(huì)員分享,可在線閱讀,更多相關(guān)《SQL數(shù)據(jù)查詢策略(5頁(yè)珍藏版)》請(qǐng)?jiān)谘b配圖網(wǎng)上搜索。

1、實(shí)驗(yàn)名稱:SQL數(shù)據(jù)查詢一、 實(shí)驗(yàn)?zāi)康模簲?shù)據(jù)查詢語(yǔ)句是SQL語(yǔ)句的重要組成部分,合理使用數(shù)據(jù)查詢語(yǔ)句,可以極大的簡(jiǎn)化應(yīng) 用程序編制、快速的定位分析數(shù)據(jù)庫(kù)系統(tǒng)的故障,查詢語(yǔ)句是編程人員與數(shù)據(jù)庫(kù)管理人員必 不可少的工具,通過實(shí)驗(yàn)達(dá)到以下目的:(1 )加深學(xué)生對(duì)查詢語(yǔ)句基本概念的理解與掌握,最終達(dá)到靈活應(yīng)用。(2)掌握SELECT語(yǔ)句的基本語(yǔ)法。(3)掌握簡(jiǎn)單單表查詢、連接查詢、嵌套查詢。(4)學(xué)會(huì)使用聚函數(shù)和進(jìn)行分組查詢。二、實(shí)驗(yàn)內(nèi)容:1、單表查詢:2、連接查詢3、嵌套查詢?nèi)?shí)驗(yàn)環(huán)境Windows xp 系統(tǒng) SQL Server2000 服務(wù)器四、程序源碼與運(yùn)行結(jié)果1、單表查詢:設(shè)計(jì)查詢語(yǔ)句完

2、成對(duì) *、distinet 、like(% 和_)、in、not in、between and、order by、group by等的應(yīng)用。(1)檢索出學(xué)生信息表中所有女生的記錄。Select * from stude nt where sex=女(2)從選課成績(jī)表中檢索出所有學(xué)生的成績(jī),并去除重復(fù)值。select disti net grade from es(3)從課程表中檢索出全部數(shù)據(jù)的信息。select * from course where en ame like 數(shù)據(jù) %(3)從學(xué)生信息表中檢索出姓王的學(xué)生的信息。select * from stude nt where sn am

3、e like 王 _(4)從成績(jī)表中找出成績(jī)等于60分的學(xué)生的性別。select sex from stude nt where sno in (select sno from cs where grade=60)(5)找出不在成績(jī)表中的學(xué)生的所有信息。select * from student where sno not in (select sno from cs)(6)在成績(jī)表中找出成績(jī)從70到85分的所有信息。select * from cs where grade betwee n 70 and 85(7) 將學(xué)生表中的所有學(xué)生的年齡按升序排列。select * from stude

4、 nt order by age(8) 檢索出沒門課程的平均分。select eno ,avg(grade) from cs group by eno2、連接查詢?cè)O(shè)計(jì)查詢語(yǔ)句,分別用兩種方式(where+連接條件和joinon)表示連接條件實(shí)現(xiàn)連 接查詢(1) 找出成績(jī)大于90分的姓名和他們所在的專業(yè)。(where+連接條件)select disti net sn ame,dept from stude nt,cs where (grade90)(2) 找出成績(jī)大于85分的姓名和他們所在的專業(yè)。(joinon)select dist inct sn ame,deptfrom stude nt

5、join cs on( stude nt.s no=cs.s no) where (grade85)3、嵌套查詢具體要完成的任務(wù)如下:1. 查詢?nèi)w學(xué)生的學(xué)號(hào)與姓名select sno,sn ame from stude nt2. 查詢?nèi)w學(xué)生的全部信息,并為學(xué)生表命名別名。select * from stude nt W,course E ,cs B where W.sno=B.s no and E.c no=B.c no3. 查全體學(xué)生的出生年份,并為年份加上標(biāo)題select 出生日期 from student4. 查詢選修了課程的學(xué)生學(xué)號(hào),要求消除重復(fù)行select sno from s

6、tude nt where sno in (select sno from cs)5. 查詢所有年齡在20歲以下的學(xué)生姓名及其年齡。select sn ame,age from stude nt where age=20 and age=23)(第二種)7. 使用IN關(guān)鍵字查詢信息系(IS)、數(shù)學(xué)系(MA和計(jì)算機(jī)科學(xué)系(CS的學(xué)生select * from stude ntwhere sno in (select sno from stude nt where dept=IS)select * from stude ntwhere sno in (select sno from stude n

7、t where dept=MA)select * from stude ntwhere sno in (select sno from student where dept=CS)8. 查詢既不是信息系、數(shù)學(xué)系,也不是計(jì)算機(jī)科學(xué)系的學(xué)生的姓名和性別。select sn ame,sex from stude ntwhere dept!=MAa nd dept!=CSa nd dept!=IS9. 查詢所有姓劉學(xué)生的姓名、學(xué)號(hào)和性別。select sn ame,s no ,sex from stude nt where sn ame like 劉 %10. 查詢名字中第2個(gè)字為陽(yáng)字的學(xué)生的姓名和學(xué)

8、號(hào)。select sn ame,s no from stude nt where sn ame like _陽(yáng)11. 查詢DB_Design課程的課程號(hào)和學(xué)分(先在 Course表中插入“ DB_Desigr”課程 信息)。select cn ame,score from course where cn ame=DB_Desig n12. 查詢沒有考試成績(jī)的學(xué)生學(xué)號(hào)和課程號(hào)。select sno,cno from cs where grade is n ull13. 查詢計(jì)算機(jī)系年齡在20歲以下的學(xué)生姓名。select sn ame from stude nt where age=321、查詢

9、有3門以上課程是90分以上的學(xué)生的學(xué)號(hào)及(90分以上的)課程數(shù)。select sno ,co un t(c no) from cs where grade=90group by sno hav ing coun t(c no) =322、查詢?nèi)w學(xué)生與選課表的笛卡爾積。select * from stude nt cross joi n course23、查詢每個(gè)學(xué)生及其選修課程的情況。select disti net * from stude nt cross join cs where stude nt.s no=cs.s no24、查詢每個(gè)學(xué)生及其選修課程的情況(去掉重復(fù)屬性)selec

10、t a.s no,s name,sex,dept,age,b.c no,c name,score,c.gradefrom stude nt a,course b,cs c where a.s no=c.s no and b.c no=c.c no25、查詢某門課程考試成績(jī)相同的學(xué)生學(xué)號(hào)和課程信息select a.s no ,b.c no ,b.c name,b.score from cs a,course bwhere a.c no=b.c no and (select coun t(*) from cs where cno=cno and grade=grade)=226、查詢每個(gè)學(xué)生的選修

11、課程包括沒有選修課程的學(xué)生(外連接)select * from stude nt a,cs b where a.s no *=b.s no27、查詢每個(gè)學(xué)生的選修課程包括沒有被學(xué)生選修的課程(外連接)select * from stude nt ,cs where stude nt.s no =*cs.s no28、查詢每個(gè)學(xué)生的選修課程即包括沒有被學(xué)生選修的課程又包括沒有被學(xué)生選修的課程(全連接)select * from stude nt full join cs on stude nt.s no=cs.s no29、查詢選修2號(hào)課程且成績(jī)?cè)?0分以上的所有學(xué)生的學(xué)號(hào)、姓名select s

12、no,sn ame from stude ntwhere sno in( select sno from cs where grade=90a nd eno=C002)30、查詢每個(gè)學(xué)生的學(xué)號(hào)、姓名、選修的課程名及成績(jī)select stude nt.s no,sn ame,c name,grade from stude nt,course,cswhere (stude nt.s no=cs.s no) and (course.c no=cs.c no)31、 查詢與“張三”在一個(gè)系學(xué)習(xí)的學(xué)生(IN)select * from stude ntwhere dept in( select dept

13、 from stude nt where sn ame=張三)32、查詢選修了課程名為“信息系統(tǒng)”的學(xué)生學(xué)號(hào)和姓名。select sno,sn ame from stude ntwhere sno in (select sno from cs where eno in (select eno from course where cn ame=信息系統(tǒng))33、查詢與“張三”在同一個(gè)系學(xué)習(xí)的學(xué)生select * from stude ntwhere dept in (select dept from stude nt where sn ame=張三)34、 查詢選修了課程1或者選修了課程2的學(xué)生(要求消除重復(fù)組 UNION(select sno from cs where cno=C001 ) UNION(select sno from cs where eno=C002)35、 查詢選修了課程1或者選修了課程2的學(xué)生(要求不消除重復(fù)組 UNION ALL(select sno from cs where cno=C001 ) UNION all(select sno from cs where eno=C002)五、實(shí)驗(yàn)總結(jié)通過本次試驗(yàn),掌握了使用SQL語(yǔ)句查詢的技巧。

展開閱讀全文
溫馨提示:
1: 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
2: 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
3.本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
5. 裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

相關(guān)資源

更多
正為您匹配相似的精品文檔
關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號(hào):ICP2024067431號(hào)-1 川公網(wǎng)安備51140202000466號(hào)


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺(tái),本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請(qǐng)立即通知裝配圖網(wǎng),我們立即給予刪除!