實驗二總結報告_第1頁
實驗二總結報告_第2頁
實驗二總結報告_第3頁
實驗二總結報告_第4頁
全文預覽已結束

下載本文檔

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

文檔簡介

1、數(shù)據庫原理與應用實驗報告實驗名稱:實驗二班 級:軟件工程學 號:姓 名:一、實驗目的1掌握使用SQL語句創(chuàng)建和刪除數(shù)據表,創(chuàng)建各種完整性約束。2掌握使用SQL語句修改表的結構。3. 掌握查詢語句的使用方法,重點掌握連接查詢和嵌套查詢。二、實驗過程1.使用SQL語句建立4個關系,:供應商表S (Sno, Sname, City)零件表P(Pno, Pname, Color, Weight)工程項目表J(Jno, Jname, City)供應情況表 SPJ(Sno, Pno, Jno, QTY)創(chuàng)建S表的語句為:create table s(sno varchar2(20) primary key

2、, sname varchar2(40) unique, city varchar2(10);語句的執(zhí)行結果為:創(chuàng)建p表的語句為:create table p(pno varchar2(20) primary key, pname varchar2(40), color varchar2(10), weight number check(weight=1 and weight2;(8)查詢零件名以“螺”字開頭的零件信息。select * from p where pname like 螺%;(9)查詢工程項目名中最后一個字為“廠”字的工程項目所在的城市。select city from j w

3、here jname like %廠;(10)查詢給每個工程供應零件的供應商的個數(shù)。select jno,count(distinct sno) from spj group by jno;(11)查詢供應數(shù)量在10002000之間(包括1000和2000)的零件名稱。select pname from p where pno in (select pno from spj group by pno having sum(qty)=1000 and sum(qty)200;(6)查詢姓名為田丕龍的學生所學課程的課程名與學分。select cname,gredit from course whe

4、re cno in (select cno from sc where sno in (select sno from student where sname=田丕龍));(7)查詢選修課程號為“160”或“304”的學生的學號。select sno from sc where cno=160 or cno=304;(8)查詢選修了課程號為“160”和“304”的學生的學號。select x.sno from sc x,sc y where x.sno=y.sno and o=160 and o=304;(9)查詢學習全部課程的學生姓名。select sname from student wh

5、ere sno in (select sno from sc group by sno having count(cno)= (select count(cno) from course);(10)查詢1994年1月1日以前出生的學生的姓名和專業(yè)。select sname,major from student where to_date(1994/01/01,yyyy/mm/dd)-birth=0;(11)查詢選修了“大學英語4”課程且成績在90分以上的學生姓名。select sname from student where sno in (select sno from sc where g

6、rade90 and cno in (select cno from course where cname=大學英語4);(12)查詢選修了5門以上課程的學生學號和姓名。select sno,sname from student where sno in (select sno from sc group by sno having count(cno)5);(13)查詢未選修“政治經濟學”課程的學生情況。select * from student where sno!=all (select sno from sc where cno in (select cno from course where cname=政治經濟學);(14)統(tǒng)計102和378號課程的選課人數(shù)及平均成績。select cno,count(sno) 人數(shù),avg(grade) from sc group by cno having cno=102 or cno=378;(15)查詢比所有“信息管理與信息系統(tǒng)”專業(yè)學生年齡都大的學生。select * from student where birth (select min(birth) from student where major=信息

溫馨提示

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

評論

0/150

提交評論