數(shù)據(jù)庫小題完整版本_第1頁
數(shù)據(jù)庫小題完整版本_第2頁
數(shù)據(jù)庫小題完整版本_第3頁
數(shù)據(jù)庫小題完整版本_第4頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1001查詢?nèi)w男同學(xué)信息情況select*fromstudentwheresex='男'1002查詢選修了1號(hào)課的學(xué)生的學(xué)號(hào)和成績(jī)selectsno,gradefromscwherecno='1'1003查詢1989年以前出生的學(xué)生學(xué)號(hào)和姓名和出生日期(提示請(qǐng)用year(csrq)函數(shù)來取出生年號(hào))selectsno,sname,csrqfromstudentwhereyear(csrq)<19891004查詢信息系所有女生的學(xué)號(hào),姓名,及所在系selectsno,sname,sdeptfromstudentwheresdept='信息系'andsex='女'1005查詢課程名是數(shù)據(jù)庫的課程號(hào)和學(xué)分selectcno,ccreditfromcoursewherecname='數(shù)據(jù)庫'1006查詢先行課號(hào)為5的課程號(hào)和課程名selectcno,cnamefromcoursewherecpno='5'1007查詢英語系90后的學(xué)生情況(注90年后出生的)select*fromstudentwheresdept='英語系'andyear(csrq)>=19901008查詢計(jì)算機(jī)系或信息系中年齡超過21歲的同學(xué)情況.(設(shè)當(dāng)前年為2010年,提示用當(dāng)前年減去出生年再與21歲比較)select*fromstudentwhere(sdept='計(jì)算機(jī)系'orsdept='信息系')and2010-year(csrq)>211009請(qǐng)將3號(hào)課及4號(hào)課學(xué)生的學(xué)號(hào)課程號(hào)及成績(jī)顯示出來selectsno,cno,gradefromscwherecno='3'orcno='4'1010查詢所有先行課程號(hào)為0且學(xué)分為2的課程名,先行課程號(hào),及學(xué)分selectcname,cpno,ccreditfromcoursewherecpno='0'andccredit=22010查詢學(xué)分為3以上(不含3),且課程名中包含著'數(shù)據(jù)'二字的所有課程名及學(xué)分selectcname,ccreditfromcoursewhereccredit>3andcnamelike'數(shù)據(jù)%'2001查詢年齡在20-23歲之間(含20與23歲)的學(xué)生姓名,系別,年齡(請(qǐng)不要用between語句提交)設(shè)當(dāng)前年為2010年selectsname,sdept,(2010-year(csrq))asagefromstudentwhere(2010-year(csrq))>=20and(2010-year(csrq))<=232002查詢選修過課程且成績(jī)大于80分的所有學(xué)生的學(xué)號(hào)(不許重復(fù))selectdistinctsnofromscwheregrade>802003請(qǐng)將選修了1號(hào)課或3號(hào)課課程的同學(xué)按課程號(hào)升序,成績(jī)降序排序select*fromscwherecno='1'orcno='3'orderbycno,gradedesc2004請(qǐng)將選了1號(hào)課程且成績(jī)?cè)?0分以上的同學(xué)按成績(jī)降序排序select*fromscwherecno='1'andgrade>60orderbygradedesc2005查詢選修了1號(hào)課的成績(jī)大于85分的學(xué)號(hào)和成績(jī)selectsno,gradefromscwherecno='1'andgrade>852006查詢所有李姓的09級(jí)同學(xué)情況select*fromstudentwheresnamelike'李%'andsnolike'09%'2007查詢所有兩字姓名的張姓85年后出生同學(xué)的姓名,性別與系別selectsname,sex,sdeptfromstudentwheresnamelike'張_'andyear(csrq)>19852008查詢名字中第3個(gè)字為鈴4月4號(hào)出生的學(xué)生的姓名和學(xué)號(hào)selectsname,snofromstudentwheresnamelike'__鈴'andmonth(csrq)=4andday(csrq)=42009查詢信息系所有不姓劉的同學(xué)的學(xué)號(hào)和姓名selectsno,snamefromstudentwheresdept='信息系'andsnamenotlike'劉%'3001查詢所有選修過數(shù)據(jù)庫或信息系統(tǒng)課的學(xué)生的姓名,課程名及成績(jī)selectsname,cname,gradefromstudent,sc,coursewherestudent.sno=sc.snoando=oandcnamein('數(shù)據(jù)庫','信息系統(tǒng)')3002查詢選修了3號(hào)課且成績(jī)大于80分的男同學(xué)的姓名,課程號(hào)及成績(jī)selectsname,cno,gradefromstudent,scwherestudent.sno=sc.snoandcno='3'andgrade>80andsex='男'3003查詢選1號(hào)課的女生姓名,課程號(hào)及成績(jī),并按課程號(hào)升序,成績(jī)降序排序selectsname,cno,gradefromstudent,scwherestudent.sno=sc.snoandcno='1'andsex='女'orderbycno,gradedesc3004查詢計(jì)算機(jī)系選修了數(shù)據(jù)庫課的所有男生的姓名,課程名及該課的成績(jī)selectsname,cname,gradefromstudent,sc,coursewherestudent.sno=sc.snoando=oandcname='數(shù)據(jù)庫'andsex='男'andsdept='計(jì)算機(jī)系'3005查詢09級(jí)選修了數(shù)據(jù)庫課的最高成績(jī).最低成績(jī)和平均成績(jī)(注用as來表示最低,最高及平均成績(jī)selectmax(grade)as'最高成績(jī)',min(grade)as'最低成績(jī)',avg(grade)as'平均成績(jī)'fromsc,coursewhereo=oandcname='數(shù)據(jù)庫'andsnolike'09%'3006查詢李勇同學(xué)選修的成績(jī)?cè)?0分以上的課程的學(xué)分總和selectsum(ccredit)as學(xué)分總合fromstudent,sc,coursewherestudent.sno=sc.snoando=oandgrade>80andsname='李勇'3007查詢09級(jí)末2位學(xué)號(hào)在15之前的選修過的課程中含有學(xué)分為4個(gè)學(xué)分課程的計(jì)算機(jī)系,男同學(xué)的姓名,課程名,學(xué)分。selectsname,cname,ccreditfromstudent,sc,coursewherestudent.sno=sc.snoando=oandstudent.snolike'09%'andright(student.sno,2)<15andccredit=4andsdept='計(jì)算機(jī)系'andsex='男'3008查詢計(jì)算機(jī)系所有選了數(shù)據(jù)庫成績(jī)?cè)?0分以上的同學(xué)的姓名及成績(jī)selectsname,gradefromstudent,sc,coursewherestudent.sno=sc.snoando=oandcname='數(shù)據(jù)庫'andsdept='計(jì)算機(jī)系'andgrade>803009查詢李勇同學(xué)所學(xué)課程的學(xué)分為2學(xué)分以上課程的學(xué)分總和及成績(jī)總和(注用as總學(xué)分)selectsum(ccredit)as總學(xué)分,sum(grade)fromstudent,sc,coursewherestudent.sno=sc.snoando=oandsname='李勇'andccredit>23010查尋選了1號(hào)課,計(jì)算機(jī)系,男生的人數(shù).selectcount(*)as人數(shù)fromstudent,scwherestudent.sno=sc.snoandcno='1'andsdept='計(jì)算機(jī)系'andsex='女';4001查詢同時(shí)選修了1號(hào)課和3號(hào)課的同學(xué)的姓名及系selectsname,sdeptfromstudentwheresnoin(selectsnofromscwheresnoin(selectsnofromscwherecno='1')andcno='3')4002查詢同時(shí)選修了數(shù)據(jù)庫及數(shù)學(xué)的同學(xué)的姓名selectsnamefromstudentwheresnoin(selectsnofromscwheresnoin(selectsnofromscwherecnoin(selectcnofromcoursewherecname='數(shù)據(jù)庫'))andcnoin(selectcnofromcoursewherecname='數(shù)學(xué)'))4003查詢選修了全部課程的同學(xué)的姓名selectsnamefromstudentwheresnoin(selectsnofromscgroupbysnohavingcount(*)=(selectcount(*)fromcourse))4004查詢與李勇同在一個(gè)系,且年齡比他小的同學(xué)的姓名(提示用year(csrq)來進(jìn)行比較)selectsnamefromstudentwheresdeptin(selectsdeptfromstudentwheresname='李勇')andyear(csrq)>(selectyear(csrq)fromstudentwheresname='李勇')4005查詢比計(jì)算機(jī)系平均年齡都大的其它系學(xué)生姓名,系和年齡。(注意不含計(jì)算機(jī)系的學(xué)生)提示設(shè)當(dāng)前年為2010,平均年齡可用avg(2010-year(csrq))表示selectsname,sdept,(2010-year(csrq))as年齡fromstudentwhere(2010-year(csrq))>all(selectavg(2010-year(csrq))fromstudentwheresdept='計(jì)算機(jī)系')andsdept<>'計(jì)算機(jī)系'4006王名同學(xué)沒有選過的課程名字selectcnamefromcoursewherecnonotin(SELECTcnoFROMSCwheresnoin(selectsnofromstudentwheresname='王名'))4007查詢一門課也沒選過的學(xué)生或選過課但平均成績(jī)不及格(<60)的同學(xué)名單selectsnamefromstudentwheresnonotin(selectsnofromsc)orsnoin(selectsnofromscgroupbysnohavingavg(grade)<60)4008查詢選修的學(xué)分總數(shù)超過8個(gè)的學(xué)生的姓名selectsnamefromstudentwheresnoin(selectsnofromsc,coursewhereo=ogroupbysnohavingsum(ccredit)>8)4009查詢選修了和王名一樣學(xué)分?jǐn)?shù)的其它同學(xué)姓名selectsnamefromstudentwheresnoin(selectsnofromsc,coursewhereo=ogroupbysnohavingsum(ccredit)=(selectsum(ccredit)fromsc,coursewhereo=oandsnoin(selectsnofromstudentwheresname='王名'))andsname<>'王名')4010查詢比平均成績(jī)比李勇的平均成績(jī)低的同學(xué)姓名selectsnamefromstudentwheresnoin(selectsnofromscgroupbysnohavingavg(grade)<(selectavg(grade)fromscwheresnoin(selectsnofromstudentwheresname='李勇')))6001用定義語句建立一個(gè)“學(xué)生”表student1,要求它的結(jié)構(gòu)與student表的結(jié)構(gòu)相同,并且規(guī)定名字不得為空,學(xué)號(hào)設(shè)為唯一(unique)createtablestudent1(snochar(8)unique,snamechar(8)notnull,sexchar(2),sdeptchar(20),csrqdate);6002用定義語句創(chuàng)建選課表要sc1,要求和sc表一樣,學(xué)號(hào)與課程號(hào)不得為空(成績(jī)類型用float)createtablesc1(snochar(8)notnull,cnochar(3)notnull,gradefloat)6003在學(xué)生表Student1中增加系(sageint)一列,缺省值為20(缺省defaultNN)altertablestudent1addsageintdefault20;6004將學(xué)生表Student1學(xué)生所屬系(sdept)長(zhǎng)度改為50,約束條件為不為空altertablestudentaltersdeptchar(50)notnull;;(C++,modify改為alter)6005創(chuàng)建一個(gè)名字為v_stu視圖,視圖字段為sno,sname,gradecreateviewv_stuasselectstudent.sno,sname,gradefromstudent,scwherestudent.sno=sc.sno6006刪除視圖文件v_studroptablev_stu6007請(qǐng)將學(xué)生表student1中的年齡sage字段刪除altertablestudent1dropsage6008以cno做主索引列(降序),grade做第二索引列(升序),對(duì)sc建索引文件,取名為idx_sccreateindexidx_sconsc(cnodesc,grade)6009刪除索引文件idx_scdropindexidx_sc//onstudent(C++下)dropindexidx_sconsc16010刪除sc1表droptablesc17002以student文傳系的1987年前出生的女生信息插入到student1表中insertintostudent1select*fromstudentwheresdept='文傳系'andsex='女'andyear(csrq)<19877003將1990年后的所有徐姓學(xué)生記錄從student表插入到student1中insertintostudent1select*fromstudentwhereyear(csrq)>=1990andsnamelike'徐%'7001將一個(gè)新同學(xué)的記錄(sno:07010150;sname:陳冬;sex:男;sdept:信息;csrq:1985-6-8)插入到STUDENT1表中。Insertintostudent1values('07010150','陳冬','男','信息','1985-6-8')7005請(qǐng)將student1表中魏玲鈴

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(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ì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論