HFUT2020資料庫實驗六 資料查詢

2021-10-06 05:54:20 字數 1494 閱讀 8064

實驗六 資料查詢

一.實驗目的

觀察查詢結果, 體會select語句實際應用;

要求學生能夠在查詢分析器中使用select語句進行簡單查詢。

熟練掌握簡單表的資料查詢、資料排序和資料連線查詢的操作方法。

二.實驗準備

成功建立了基本表。

了解簡單select語句的用法。

熟悉查詢分析器中的sql指令碼執行環境。

三.實驗要求

完成所要求的全部查詢。

注意操作結果的截圖與儲存,供撰寫實驗報告使用。

四.實驗內容

所有的查詢全部用transact-sql語句實現。此部分查詢包括投影、選擇條件表達、資料排序、使用臨時表等。

對educ資料庫實現以下查詢:

(可根據資料表中的資料,對要求中的條件作出調整!)

查詢「計算機應用」專業的學生學號和姓名;

查詢選修了課程的學生學號;

查詢選修課程0001 且成績在80-90 之間的學生學號和成績,並將成績乘以係數0.75 輸出;

查詢「計算機應用」和「數學」專業的姓「張」的學生的資訊。

查詢「0001」課程的成績高於張三的學生學號和成績;

查詢沒有選修「0002」課程的學生姓名。

五.實驗步驟

在查詢分析器中完成上述所有查詢。
select sno,sname

from student,class

where student.clsno=class.clsno and class.specialty = '計算機';

select distinct sno

from sc;

select sno,grade*0.75

from sc

where cno='0001'and grade between 80 and 90;

select student.*,class.specialty

from student,class

where student.sname like '張%'

and student.clsno=class.clsno

and class.specialty in('數學','外國語');

select sno,grade

from sc

where cno='0001'

and grade>(

select grade

from sc,student

where student.sno=sc.sno

and student.sname='張二'

and sc.cno='0001'

);select sname

from student

where not exists

(select*

from sc

where sno=student.sno and cno='0002');

資料庫實驗六

實驗六 資料庫程式設計 一 實驗目的 1.掌握觸發器的概念,了解觸發器的型別 2.掌握儲存過程的建立與執行方法 二 實驗內容 建立觸發器trigger delete,實現以下功能 當訂單表的資料被刪除時,顯示提示資訊 訂單表記錄被修改了 create trigger trigger delete o...

資料庫實驗六 儲存過程

什麼是儲存過程?是一組被編譯在一起的t sql語句的集合,它們被集合在一起以完成乙個特定的任務。儲存過程的分類 系統儲存過程 擴充套件儲存過程 提供從sql server到外部程式的介面,以便進行各種維護活動 使用者自定義的儲存過程 儲存過程的作用 1.模組化程式設計 建立乙個儲存過程存放在資料庫中...

資料庫(實驗2 資料庫表)

建立資料庫 建立資料庫資料檔案 create database testbase2 on name testbase2 data,filename d 張小山資料庫 lianxi2 testbase2 data.mdf size 5mb,maxsize 50mb,filegrowth 20 建立資料...