數據庫小題完整版本_第1頁
數據庫小題完整版本_第2頁
數據庫小題完整版本_第3頁
數據庫小題完整版本_第4頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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

溫馨提示

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

評論

0/150

提交評論