![數(shù)據(jù)庫(kù)第二次試驗(yàn)_第1頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/7/a5350a46-35aa-4b1c-b742-2b8c1c41ccce/a5350a46-35aa-4b1c-b742-2b8c1c41ccce1.gif)
![數(shù)據(jù)庫(kù)第二次試驗(yàn)_第2頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/7/a5350a46-35aa-4b1c-b742-2b8c1c41ccce/a5350a46-35aa-4b1c-b742-2b8c1c41ccce2.gif)
![數(shù)據(jù)庫(kù)第二次試驗(yàn)_第3頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/7/a5350a46-35aa-4b1c-b742-2b8c1c41ccce/a5350a46-35aa-4b1c-b742-2b8c1c41ccce3.gif)
![數(shù)據(jù)庫(kù)第二次試驗(yàn)_第4頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/7/a5350a46-35aa-4b1c-b742-2b8c1c41ccce/a5350a46-35aa-4b1c-b742-2b8c1c41ccce4.gif)
![數(shù)據(jù)庫(kù)第二次試驗(yàn)_第5頁(yè)](http://file3.renrendoc.com/fileroot_temp3/2022-3/7/a5350a46-35aa-4b1c-b742-2b8c1c41ccce/a5350a46-35aa-4b1c-b742-2b8c1c41ccce5.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、南昌航空大學(xué)實(shí)驗(yàn)報(bào)告2016 年 4 月 14日課程名稱:數(shù)據(jù)庫(kù)系統(tǒng)概論 實(shí)驗(yàn)名稱: SQL-select查詢操作 學(xué)號(hào): 14204129 姓名: 袁小峰 同組人: 指導(dǎo)教師評(píng)定: 簽名: 一、實(shí)驗(yàn)?zāi)康模罕砘蛞晥D數(shù)據(jù)的各種查詢(與統(tǒng)計(jì))SQL命令操作,具體分為:1、 了解查詢的概念和方法;2、 掌握SQL Sever集成管理器查詢子窗口中執(zhí)行SELECT操作方法;3、 掌握SELECT語(yǔ)句在單表查詢中的應(yīng)用;4、 掌握SELECT語(yǔ)句在多表查詢中的應(yīng)用;5、 掌握SELECT語(yǔ)句在復(fù)雜查詢中的使用方法;二、實(shí)驗(yàn)內(nèi)容與要求:請(qǐng)有選擇地實(shí)踐以下各題。(1)基于“教學(xué)管理”數(shù)據(jù)庫(kù)jxgl,試用SQ
2、L的查詢語(yǔ)句表達(dá)下列查詢: Jxgl數(shù)據(jù)庫(kù)的建立: 代碼:Create database jxglUSE jxglGOCreate Table Student(Sno CHAR(5) not null primary key(Sno), Sname varchar(20), Sage smallint check(Sage>=15 AND Sage<=45), Ssex char(2) default'男'check(Ssex='男' OR Ssex='女' ), Sdept char(2); Create Table Course
3、(Cno char(2)NOT NULL primary key(Cno), Cname VARCHAR(20), Cpno char(2), Ccredit SMALLINT); Create Table SC (Sno char(5) NOT NULL CONSTRAINT S_F FOREIGN KEY REFERENCES Student(Sno), Cno CHAR(2) NOT NULL, Grade smallint check (Grade IS NULL)OR(Grade between 0 and 100), Primary key(Sno,Cno), foreign ke
4、y(Cno) references Course(Cno); insert into Student values('98001','錢橫',18,'男','CS'); insert into Student values('98002','王林',19,'女','CS'); insert into Student values('98003','李民',20,'男','IS'); insert into
5、 Student values('98004','趙三',16,'女','MA'); insert into Course values('1','數(shù)據(jù)庫(kù)系統(tǒng)','5',4); insert into Course values('2','數(shù)學(xué)分析',null,2); insert into Course values('3','信息系統(tǒng)導(dǎo)論','1',3); insert into Course val
6、ues('4','操作系統(tǒng)_原理','6',3); insert into Course values('5','數(shù)據(jù)結(jié)構(gòu)','7',4); insert into Course values('6','數(shù)據(jù)處理基礎(chǔ)',null,4); insert into Course values('7','C語(yǔ)言','6',3); insert into SC values('98001','1'
7、,87); insert into SC values('98001','2',67); insert into SC values('98001','3',90); insert into SC values('98002','2',95); insert into SC values('98002','3',88);圖: Student表:Course表:SC表:1、 檢索年齡大于23歲的男學(xué)生的學(xué)號(hào)和姓名;代碼:select sno,sname 圖:from s
8、tudent where sage>23 and ssex='男'2、 檢索至少選修一門課程的學(xué)生的學(xué)號(hào)和姓名;代碼:select sname from studentwhere sno in圖: (select sno from sc )and ssex='女' 3、 檢索王同學(xué)不學(xué)的課程的課程號(hào);代碼:圖:select cno from courseexceptselect cnofrom sc where sno in (select sno from student where sname Like '王%' ); 4、 檢索至少選
9、修兩門課程的學(xué)生學(xué)號(hào);代碼:圖:select distinct s1.snofrom sc s1,sc s2where s1.sno=s2.sno and o!=o; 5、 檢索全部學(xué)生都選修的課程的課程號(hào)和課程名;代碼:select o,cnamefrom sc,coursewhere o=o 圖:group by o,cnamehaving count(*)= (select count(*) from Student ); 6、 檢索選修了所有3學(xué)分課程的學(xué)生學(xué)號(hào);代碼:圖:select sno from course,scwhere ccredit=3 and o=o; (2)基于“教
10、學(xué)管理”數(shù)據(jù)庫(kù)jxgl,試用SQL的查詢語(yǔ)句表達(dá)下列查詢:1、統(tǒng)計(jì)所有學(xué)生選修的課程門數(shù);代碼:select Student.sno,count(cno)from Student left outer join SC on (Student.sno = SC.sno)group by Student.Sno;圖: 2、求選修4號(hào)課程的學(xué)生的平均成績(jī);代碼:圖:select avg(sage) from studentwhere sno in (select sno from sc where cno='4' );3、求學(xué)分為3的每門課程的平均成績(jī);代碼:圖:select avg
11、(grade) from scwhere cno in (select cno from course where (ccredit=3);4、統(tǒng)計(jì)每門課程的學(xué)生選修人數(shù),超過(guò)3人的課程才統(tǒng)計(jì),要求輸出課程號(hào)和選修人數(shù),查詢結(jié)果按人數(shù)降序排列,若人數(shù)相同,按課程號(hào)升序排列;代碼:圖:select cno,count(sno) from scgroup by cnohaving count(*)>0order by count(*) desc,cno;5、 檢索學(xué)號(hào)比王林同學(xué)大,而年齡他小的學(xué)生姓名;代碼:圖:select sname from studentwhere sno >
12、(select sno from student where sname='王林' ) and sage < (select sage from student where sname='王林' ); 6、 檢索姓名以王字打頭的所有學(xué)生姓名和年齡;代碼:圖:select sname,sage from studentwhere sname like '王%'7、 在SC中檢索成績(jī)?yōu)榭罩档膶W(xué)生學(xué)號(hào)和課程號(hào);代碼:圖:select sno,cno from scwhere grade is null;8、 求年齡大于女同學(xué)平均年齡的男學(xué)生的姓名
13、和年齡;代碼:圖:select sname,sage from studentwhere ssex='男' and sage> (select avg(sage) from student where ssex='女' );9、 求年齡大于所有女同學(xué)年齡的男同學(xué)的姓名和年齡;代碼:圖:select sname,sage from studentwhere sage>all (select sage from student where ssex='女' );10、 檢索所有比“王林”年齡大的學(xué)生姓名、年齡和性別;代碼: 圖:selec
14、t sname,sage,ssex from studentwhere sage> (select sage from student where sname='王林' );11、 檢索選修2號(hào)課程的學(xué)生中成績(jī)最高的學(xué)生的學(xué)號(hào);代碼:圖:select sno from scwhere grade in (select max(grade) from sc where cno='2' ); 12、 檢索學(xué)生姓名及其所選修課程的課程號(hào)和成績(jī);代碼:圖:select sname,cno,grade from student,scwhere student.sno=sc.sno; 13、 檢索選修4門以上課程的學(xué)生總成績(jī)(不統(tǒng)計(jì)不及格的課程),并要求按總成績(jī)的
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝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ù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2023三年級(jí)語(yǔ)文下冊(cè) 第一單元 2 燕子配套說(shuō)課稿 新人教版
- 2024-2025學(xué)年高中語(yǔ)文 名著導(dǎo)讀 莎士比亞戲劇說(shuō)課稿 新人教版必修4
- 9古詩(shī)三首清明說(shuō)課稿2023-2024學(xué)年統(tǒng)編版語(yǔ)文三年級(jí)下冊(cè)
- Unit 4 Natural Disasters Reading for Writing 說(shuō)課稿-2024-2025學(xué)年高中英語(yǔ)人教版(2019)必修第一冊(cè)
- Unit 2 lconic Attractions Learning About Language (1)說(shuō)課稿 2023-2024學(xué)年高中英語(yǔ)人教版選擇性第四冊(cè)
- 2025主體信用評(píng)級(jí)合同
- 2025吊頂勞務(wù)承包合同
- 19《夜宿山寺》(說(shuō)課稿)2024-2025學(xué)年部編版語(yǔ)文二年級(jí)上冊(cè)
- 2024-2025學(xué)年高中生物 第一章 人體的內(nèi)環(huán)境與穩(wěn)態(tài) 專題1.2 內(nèi)環(huán)境穩(wěn)態(tài)的重要性說(shuō)課稿(基礎(chǔ)版)新人教版必修3001
- 7《壓歲錢的使用與思考》(說(shuō)課稿)-2023-2024學(xué)年四年級(jí)下冊(cè)綜合實(shí)踐活動(dòng)長(zhǎng)春版
- 北京市豐臺(tái)區(qū)2024-2025學(xué)年九年級(jí)上學(xué)期期末語(yǔ)文試題(含答案)
- 計(jì)劃供貨時(shí)間方案
- 2024年石柱土家族自治縣中醫(yī)院高層次衛(wèi)技人才招聘筆試歷年參考題庫(kù)頻考點(diǎn)附帶答案
- 西藏事業(yè)單位c類歷年真題
- 2024人教新目標(biāo)(Go for it)八年級(jí)英語(yǔ)下冊(cè)【第1-10單元】全冊(cè) 知識(shí)點(diǎn)總結(jié)
- 七年級(jí)英語(yǔ)下學(xué)期開(kāi)學(xué)考試(深圳專用)-2022-2023學(xué)年七年級(jí)英語(yǔ)下冊(cè)單元重難點(diǎn)易錯(cuò)題精練(牛津深圳版)
- 部編版語(yǔ)文小學(xué)二年級(jí)下冊(cè)第一單元集體備課(教材解讀)
- 房屋市政工程生產(chǎn)安全重大事故隱患判定標(biāo)準(zhǔn)(2024版)宣傳畫冊(cè)
- 杭州市房地產(chǎn)經(jīng)紀(jì)服務(wù)合同
- 漢語(yǔ)言文學(xué)論文6000字
- 樹(shù)立正確的世界觀人生觀價(jià)值觀課件
評(píng)論
0/150
提交評(píng)論