




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、數(shù)據(jù)庫(kù)系統(tǒng)實(shí)驗(yàn)報(bào)告學(xué)院計(jì)算機(jī)學(xué)院專業(yè)計(jì)算機(jī)科學(xué)寧技術(shù)班級(jí)級(jí)班學(xué)號(hào)姓名指導(dǎo)教師(2016 年 12 月)實(shí)驗(yàn)_=_題冃數(shù)據(jù)庫(kù)及基本表的建立實(shí)驗(yàn)二題目查詢數(shù)據(jù)庫(kù)實(shí)驗(yàn)三題目創(chuàng)建和使用視圖、索引、存儲(chǔ)過程實(shí)驗(yàn)四題目小型數(shù)據(jù)庫(kù)規(guī)劃設(shè)計(jì)實(shí)驗(yàn)平臺(tái):sql sever 2005實(shí)驗(yàn)題目實(shí)驗(yàn)數(shù)據(jù)庫(kù)及基本表的建立一、實(shí)驗(yàn)?zāi)康?、掌握sql server的查詢分析器和企業(yè)管理器的使用;2、掌握創(chuàng)建數(shù)據(jù)庫(kù)和表的操作;二、實(shí)驗(yàn)內(nèi)容和要求1、分別使用sql語(yǔ)句、企業(yè)管理器(enterprise manager)創(chuàng)建數(shù)據(jù)庫(kù);2、使用sql語(yǔ)句、企業(yè)管理器(enterprise manager)創(chuàng)建數(shù)據(jù)庫(kù)表;三、實(shí)驗(yàn)主要儀器
2、設(shè)備和材料1 計(jì)算機(jī)及操作系統(tǒng):pc機(jī),windows 2000/xp;2數(shù)據(jù)庫(kù)管理系統(tǒng):sql sever 2000/2003/2005;四、實(shí)驗(yàn)方法、步驟及結(jié)果測(cè)試創(chuàng)建一個(gè)教學(xué)管理數(shù)據(jù)庫(kù)sc,其描述的信息有:學(xué)生信息、課程信息、教師信息、學(xué) 生選課成績(jī)、授課信息、班級(jí)信息、系部信息、專業(yè)信息。創(chuàng)建:student表(學(xué)生信息表)、course表(課程信息表)、teacher表(教師信息表)、student .course表(學(xué)生選課成績(jī)表)、teacher_course表(教師上課課表)等。1、創(chuàng)建數(shù)據(jù)庫(kù):確定數(shù)據(jù)庫(kù)名稱;數(shù)據(jù)庫(kù)用于學(xué)生管理,命名為sc確定數(shù)據(jù)庫(kù)的位置;要求:數(shù)據(jù)文件和日志
3、文件分別存儲(chǔ)在e盤自己的目錄下。確定數(shù)據(jù)庫(kù)的大??;根據(jù)實(shí)際的數(shù)據(jù)量確定數(shù)據(jù)文件的初始大小為30mb,日志文件的初始大小為3mbo確定數(shù)據(jù)庫(kù)的增長(zhǎng);根據(jù)實(shí)際情況,確定數(shù)據(jù)文件按20%增長(zhǎng),日志文件按1mb增長(zhǎng)。、利用查詢分析器(query analyzer),使用sql語(yǔ)句指定參數(shù)創(chuàng)建數(shù)據(jù)庫(kù); 實(shí)現(xiàn)代碼及截圖:查詢分析器執(zhí)行情況:sql語(yǔ)句及執(zhí)行結(jié)果截圖顯示create database sc_3114006159on primaryi:name = sc_311400 6159_data,filename='e:3114006159sc_311400615size=30jfilegro
4、wth=20%)log oni:name = sc_3 11400 615900,filename='e:3114006159sc_311400615size=3zfilegrowth=1)sql語(yǔ)句create database sc 3114006159on primary(name=sc_3114006159_data,filename=,e:3114006159sc_3114006159.mdf*,size=30,filegrowth=20%)log on(name二sc_3114006159_log,filename=,e:3114006159sc_3114006159.1d
5、f*,size=3zfilegrowth=1)鬲消息命令已成功完成。2、創(chuàng)建基本表利用查詢分析器,使用sql語(yǔ)句方式創(chuàng)建方式將下面各表建立到教學(xué)管理數(shù)據(jù)庫(kù)中。(1)創(chuàng)建student表字段名代碼類型約束學(xué)號(hào)s_nochar (8)主鍵姓名snamechar (8)非空性別sexchar (2)岀生日期sbi rthdaysma11 datet i me學(xué)生所在院系編號(hào)dnochar (6)外鍵專業(yè)代碼spnochar (8)外鍵班級(jí)編碼class nochar (2)創(chuàng)建course表字段名代碼類型約束課程編號(hào)enochar (10)主鍵課程名稱cn amechar (20)非空專業(yè)代碼spn
6、ochar (8)外鍵課程類型編號(hào)ctnotinyi nt理論學(xué)時(shí)lecturet inyint實(shí)驗(yàn)學(xué)時(shí)exper imenttinyint開課學(xué)期semestert i ny i nt課程學(xué)分credittinyint(3)創(chuàng)建student course表字段名代碼類型約束學(xué)號(hào)s_nochar (8)主鍵,與student表中s no外鍵關(guān)聯(lián),級(jí)聯(lián)刪除上課編號(hào)tcidsmai iint主鍵學(xué)生成績(jī)scoretinyint(4)創(chuàng)建 teacher 表字段名代碼類型約束教師編號(hào)t nochar (8)主鍵教師姓名t namechar (8)非空性別t sexchar (2)出生日期t b i
7、 rthdaysmai i datetime教師所在院系編號(hào)dnochar (6)外鍵職稱tech t i 11echar (10)創(chuàng)建系部表(department)字段名代碼類型約束院系編號(hào)dnochar (6)主鍵院系名稱dept namechar (20)非空院系負(fù)責(zé)人headerchar (8)創(chuàng)建專業(yè)信息表(speciality)字段名代碼類型約束專業(yè)代碼spnochar (8)主鍵院系編號(hào)dnochar (6)外鍵,非空專業(yè)名稱spnamechar (20)非空(7)創(chuàng)建 teacher cowrse 表字段名代碼類型約束上課編號(hào)tcidsmailint主鍵教師編號(hào)t nochar
8、 (8)外鍵專業(yè)代碼spnochar (8)外鍵班級(jí)編碼class nochar 課程編號(hào)enochar (10)非空,外鍵學(xué)期semesterchar 學(xué)年school yearchar (10)(8)創(chuàng)建班級(jí)表(class)字段名代碼類型約束專業(yè)代碼spnochar (8)主鍵,與speciality表中spno外鍵關(guān)聯(lián),班級(jí)編碼class nochar 主鍵,班負(fù)責(zé)人headerchar (8)3、查看各數(shù)據(jù)表之間的關(guān)系,生成數(shù)據(jù)庫(kù)關(guān)系圖。生成數(shù)據(jù)庫(kù)關(guān)系圖截圖顯示查詢分析器執(zhí)行情況:sql語(yǔ)句及執(zhí)行結(jié)果截圖顯示(local).scj114006159 - c:jsqry4sqluse s
9、c_3114006159go 一create table scudent_311400615 (s_no char(8)primary key, sname char(8) not null, sex char(2)r sbirthday sitalldatetxite r dno char(6), spno char(8) r class_no char(4 i): 1create table course_3114006159 | (eno char(10) primary key, cname char(20) not null, spno char(8), ctno tinyincr
10、lecture tinyinc, experiment txnylnt.命令已成功完成。4、創(chuàng)建各表的實(shí)現(xiàn)代碼及截圖:sql語(yǔ)句use sc_3114006159gocreate table student_3114006159 (s_no char(8)primary key,sname char(8) not null, sex char (2),sbirthdey smalldatetime, dno char (6),spno char (8), class_no char (4);create table course_3114006159 (eno char (10) primar
11、y key,cname char(20) not null, spno char(8), ctno tinyint, lecture tinyint, experiment tinyint, semester tinyint, credit tinyint);create tablest uden t_cou:rse_3114 006159(s_no char (8), tcid smallint, score tinyint, primary key(s_no, tcid);create table teacher_3114006159 (t_no char (8) primary key,
12、t_name char (8) not null, t_sex char (2),t_birthday smalldatetime, dno char (6),tech_title char (10);create tabledeparment_3114006159(dno char (6) primary key, dept_name char(20) not null, header char (8)create table speciality_3114006159(spno char(8) primary key, dno char (6) not null, spname char
13、(20) not null);create table teacher_course_3114006159(tcid smallint primary key, t_no char (8),spno char (8), class_no char (4), eno char (10) not null, semester char (6), schoolyear char (10);create table class_3114006159 (spno char(8),class_no char (4), header char (8), primary key (spno,class_no)
14、;alter table student_3114006159 add foreign key (dno)referencesdeparment_3114006159(dno);alter table student_3114006159add foreign key (spno) references speciality_3114006159(spno); alter table course_3114006159add foreign key (spno) references speciality_3114006159(spno); alter table student_course
15、_3114006159add foreign key (s_no) references student_3114006159(s_no); alter table teacher_3114006159add foreign key (dno)referencesdeparment_3114006159(dno);alter tablespeciality_3114006159add foreign key (dno)references deparment_3114006159 (dno);alter table teacher_course_3114006159add foreign ke
16、y (t_no) references teacher_3114006159(t_no);alter table teacher_course_3114006159add foreign key (spno) references speciality_3114006159(spno); alter table teacher_course_3114 006159add foreign key (eno) references course_3114 006159(eno); alter table class_3114006159addforeignkey(spno)referencessp
17、eciality_3114 006159(spno);5、利用查詢分析器修改上述各表。(1) 、用insert語(yǔ)句向各個(gè)表中插入數(shù)據(jù)錄入5條記錄。錄入時(shí)注意體會(huì)外鍵約束。 實(shí)現(xiàn)代碼及截圖:查詢分析器執(zhí)行情況:sql語(yǔ)句及執(zhí)行結(jié)果顯示insert into deparment_3114006159 values ('659801 ,計(jì)算機(jī)-,周杰倫 t ; insert into deparment_3114006159 values (* 659802 ,機(jī)電 j,陳奕迅冷;insert into deparment_3114006159 values ('659803 國(guó)語(yǔ)&
18、#39;,1 章子怡'); insert into deparment_3114006159 values ( ' 659804 * ,,土木 j,梁朝偉,);insert into deparment_3114006159 values ('659805 '環(huán)境'張國(guó)榮');insert into teacher_3114006159 values('65980101 ,劉德華 j,男1, 1975-03-25 j 659801 j 1 高級(jí));dnodept nameheader比q1豳計(jì)算機(jī)周杰倫659802機(jī)電陳賣迅659803外
19、國(guó)語(yǔ)章子怡659804土木梁朝偉659805壞墳張國(guó)榮dtsktop31140061s931i40u015z.we!197w1/2$ 0003006海20j卑醞“eewn65w011955/5/21600300103/2(0:00aw實(shí)驗(yàn)結(jié)果截圖顯示(插入數(shù)據(jù)的表格)desktop-696du46.-rment_3114006159 (local).scj!insert into teacher_3114006159 values('65980201 ,周潤(rùn)發(fā),'男 ',*1964-09-24 * ,,659802 j '高級(jí); insert into teac
20、her_3114006159 values ('65980301*,,張學(xué)友 j,男 1, ,1956-06-15'/ ' 659803* z '高級(jí)'); insert into teacher_3114006159 values659804ou ,,張曼玉,'女 1965-04-21j 659804'高級(jí),);insert into teacher_3114006159 values ( ' 659805011 ,'陳坤 1, 1 男11988-03-02 * , ' 659805* ,'高級(jí)'
21、);insert into speciality_3114006159 values ( ' 65980110* , '659801','計(jì)算機(jī) 科學(xué)與技術(shù),);insert into speciality_3114006159 values ( 1 65980210', '659802','自動(dòng)化 ');insert into speciality_3114006159 values ( ' 65980310 659803,'商務(wù)英 語(yǔ)t;insert into speciality_3114006159
22、 values ( 1 65980410' z ' 659804 j,土木工 程t;insert into speciality_3114006159 values ( ' 65980510' , 1 659805*,'環(huán)境工 程');spnodnospname659801計(jì)算機(jī)科學(xué)與65980210659802自機(jī)65980310659803商勢(shì)英語(yǔ)65980410659804土木工程65980510659805壞境工程desktop 696du46_ialityj114006159 (iocal).scj11spnoclass.noheade
23、r擁測(cè)im1401劉律華659802101402659803101403張學(xué)友659804101404張曼玉659805101405陳坤desktop 696du46.s classj114006159 (local).scj!”351mi二.man.desktop 696du46.course 31140061s9 (local).scjls_notidscoreb1140001hs19631140002367311400032913114000448931140005596insert into class_3114006159 values ( ' 65980110' ,
24、 11401',】劉德華t ;insert into class_3114006159 values ('65980210', '1402','周潤(rùn)發(fā)');insert into class_3114006159 values (1 65980310* z 74 03 j,張學(xué)友t ;insert into class_3114006159 values (' 65980410 1 z 11404 ' z,張曼玉 j ;insert into class_3114006159 values ( 1 659805101, ,
25、1405,,陳坤 1);insert into course_3114006159values ( ' 6598011001 * ,'數(shù)據(jù)庫(kù)*, * 65980110*,1,48,12,1,2);insert into course_3114006159 values ( * 6598021001',,制圖65980210,2,56,6,2,2);insert into course_3114006159 values ( ' 65980310011 , ' 口語(yǔ)65980310,3,48,0,1,4);insert into course_311400
26、6159 values ( * 65980410011 ,'建筑學(xué)'65980410',4,48,12,1,2);insert into course_3114006159 values ( ' 65980510011 ,'基礎(chǔ)化學(xué)'65980510',5,48,12,1,2);insert into teacher_course_3114006159 values (1, '65980101*, '65980110t4 01 '6598011001', 1學(xué)期*, 1 第二學(xué)年 *);insert int
27、o teacher_course_3114006159 values (2, * 65980201 *, * 65980210*, *14 02', 6598021001,'一 學(xué)期*, 1 第二學(xué)年 *);insert into teacher_course_3114006159 values (3, 65980301,'65980310*, *14 03', 6598031001,'一 學(xué)期*, 1 第二學(xué)年 *);insert into teacher_course_3114006159 values (4, * 65980401 * z * 65
28、980410*, *14 04', 6598041001,'一學(xué)期*, 1 第二學(xué)年 *);insert into teacher_course_3114006159 values (5z '65980501', '65980510', *14 05', '6598051001','一學(xué)期*, 1 第二學(xué)年 *);insert into student_3114006159values('31140001,,王小波,男 *1997-01-03 '659801', '65980110*
29、 ,'1401');insert into student_3114006159 values('31140002,/ 1 韓寒','男1992-03-23','659802','65980210* ,*14021);insert into student_3114006159values ('31140003*, 1 莫言,,'男 '1997-06-15', '659803', '65980310' ,1403*);insert into student_3
30、114006159 values('31140004 ,三毛 j '女 '1994-05-30', 659804,65980410,t404 1 );insert into student_3114006159 values ( '31140005,郭敬明 j,男 ',1995-12-03, 659805,'65980510* ,'1405');insert intostudent_course_3114006159 values('31140001,l,96);insert into student_course
31、_3114006159 values ( '31140002 3, 67);insert into student_course_3114006159 values('31140003',2, 91);insert into student_course_3114006159 values('31140004,z4z89);insert intostu den t_cou:rse_3114 006159values('31140005*,5,96);共8組(共8個(gè)表)(2)、用update語(yǔ)句更改student表中數(shù)據(jù); 實(shí)現(xiàn)代碼:use sc_3114
32、006159update student_3114006159set sname= * 寸上春樹,where sname='莫言'student表更改前的內(nèi)容截圖更型分析 dmtopwwuwui刪m炯,喻gue測(cè) 誨強(qiáng)辭送student表更改后的內(nèi)容截圖顯示"0 煩 勉irt沏如輒剛m呦腳伽)6酬鯽血伽)酬刪那伽)刪楓甌酬m331«311565®101103snosranesexsbrway(hospnodassno班i1997/1/30m 65980169900110101儷21992/3/230m m65980210h023i1wws«
33、;號(hào)w6/150m m65980310h0331ww04弐攵1w/5/xoo m6599041010431kw05刪1鳥1 刪 12/30伽0 659805刪101c5desktop-6%du4ludentj114006159 (lc450114oo6159sqlqu刑妙習(xí)(3)、用delete語(yǔ)句刪除student表中數(shù)據(jù); 實(shí)現(xiàn)代碼:use sc_3114006159deletefrom student_course_3114006159 where s_no in(select s_nofrom student_3114006159where sname= 1 郭敬明 1 );delet
34、efrom student 3114006159where sname= 1 郭敬明student表更改前的內(nèi)容截圖顯示查詢分析dbktopwludentj1«159脅風(fēng)川嘏恥如軻時(shí) 犠戀懿攙s.no測(cè)swmf31wom2勰星31»og唄丑 i31«酈¥may加das no1937/1/300 6598016蒯10141659802w10142哪 1w 65580314)3酈顧腳w10翩腳則曲$酬1«5sdosnamesexsbrthdaydnospnodass.noeittifc王小披1997/1/3 00«l 6553016598
35、0110140131140002£ 1992/3/23(m0 659302653802101402311w031997/6/150i»joo 65980365980310140331104i1994/5/m oimjoo 659804659804101404student表更改后的內(nèi)容截圖顯示ktop-6%du4a-udenu1140061s9 (loca .scj114006159 sqlqueisql* 活爲(wèi)自豁殳誨五、實(shí)驗(yàn)中出現(xiàn)的問題及解決方案在插入數(shù)據(jù)時(shí)沒注意外鍵約束,結(jié)果導(dǎo)致插入失敗,于是根據(jù)數(shù)據(jù)表關(guān)系圖先插入沒有 外鍵約束的表,再根據(jù)外鍵約束關(guān)系按照一定順序插入
36、表。在刪除student的元組時(shí),因?yàn)?其主鍵被student course表外鍵所參照,所以無(wú)法刪除,于是先刪除student course表中 的元組,再刪除student中的元組。六、思考題1、說(shuō)明數(shù)據(jù)庫(kù)中的表和數(shù)據(jù)文件的關(guān)系。答:表存儲(chǔ)于數(shù)據(jù)文件中,一個(gè)數(shù)據(jù)文件可以存儲(chǔ)多個(gè)表。2、數(shù)據(jù)庫(kù)中的日志文件能否單獨(dú)修改?不能,sql server數(shù)據(jù)庫(kù)都有l(wèi)og日志文件,log日志文件記錄用戶對(duì)數(shù)據(jù)庫(kù)修改的操 作,只有數(shù)據(jù)庫(kù)發(fā)生更改時(shí),日志文件才會(huì)發(fā)生更改,不能單獨(dú)更改。3、附加練習(xí)題.(代碼以及運(yùn)行結(jié)果采用截圖顯示)(1)將計(jì)算機(jī)專業(yè)所右學(xué)生的數(shù)據(jù)庫(kù)原理的成績(jī)?cè)黾?0分代碼以及運(yùn)行結(jié)果:(l
37、ocal).scj! 14006159 - c:vasq.ry6.sql (local).sc use sc_3114006159update student_course_3114006159 s皂匸 score=score-f10where tcid in(select tcidfrom course_3114006159where cname=1 數(shù)據(jù)庫(kù) *)and(select s_nofrom student_3114006159where dno mselect dnofroir. deparn:ent_3114006159 where dept_naire * 計(jì):頁(yè)機(jī)1 id消
38、息行受影響)(2) 刪除計(jì)算機(jī)專業(yè)所有學(xué)生的數(shù)據(jù)庫(kù)原理的選修信息 代碼以及運(yùn)行結(jié)果:(1ocal).sc_3114006159 c:vsq.6.sql* (local).sc use sc_3114006159 deletefrom student_course_3114006159 where tcid in(select tcidfrom course_3114006159 where cname= ,數(shù)據(jù)庫(kù)ta cds_no in(select s_no from student_3114006159 where dno in(select dnofrom deparment_31140
39、06159 where dept_nanie='計(jì)算機(jī) *);c自消息4行受影響) 為speciality的spname添加唯一約束代碼以及運(yùn)行結(jié)果:(local).scj114006159 sqlquerys.sql*i use sc_3114006159alter cable speciality_3114006159 add unique(spname); 為student_course的score設(shè)置檢查約束 代碼以及運(yùn)行結(jié)果:(local).scj! 14006159 sqlquerys.sqhuse sc_3114006159alter table student_cour
40、se_3114006159add constraint ck_studenr_c|dur3e_3114006159 check(score>0and score<150 ;j消息命令已成功完成。實(shí)驗(yàn)題目實(shí)驗(yàn)二一、實(shí)驗(yàn)?zāi)康氖煜ql語(yǔ)句的基本使用方法,學(xué)習(xí)如何編寫sql語(yǔ)句來(lái)實(shí)現(xiàn)查詢1、掌握基本的select查詢及其相關(guān)子句的使用;2、掌握復(fù)雜的select查詢,如多表查詢、子查詢、連接查詢和嵌套查詢。二、實(shí)驗(yàn)內(nèi)容和要求使用sql查詢分析器查詢數(shù)據(jù),練習(xí)查詢語(yǔ)句的使用,掌握select語(yǔ)句的完整結(jié) 構(gòu),包括簡(jiǎn)單查詢、嵌套查詢、連接查詢等基本實(shí)現(xiàn)方法,掌握存儲(chǔ)查詢結(jié)果的方法,體會(huì) 各種
41、查詢的異同及相互之間的轉(zhuǎn)換,體會(huì)各種查詢的執(zhí)行過程,為簡(jiǎn)單綜合應(yīng)用打下良好的 基礎(chǔ)。三、實(shí)驗(yàn)主要儀器設(shè)備和材料1計(jì)算機(jī)及操作系統(tǒng):pc機(jī),windows 2000/xp;2數(shù)據(jù)庫(kù)管pf!系統(tǒng):sql sever 2000/2003/2005;四、實(shí)驗(yàn)方法、步驟及結(jié)果測(cè)試要求用select完成以下查詢,1、對(duì)實(shí)驗(yàn)一建立的數(shù)據(jù)庫(kù)表進(jìn)行查詢簡(jiǎn)單查詢:(1)、查詢?nèi)繉W(xué)生的學(xué)號(hào)、姓名、性別和出身年月口。實(shí)現(xiàn)代碼及査詢結(jié)果截圖:格式如下查詢分析器執(zhí)行情況:查詢結(jié)果截圖顯示sql語(yǔ)句及執(zhí)行結(jié)果顯示s_nosnamesexsbirthdayuse sc_3m40061591 31140001 !王小波男19
42、97-01-03 00:00:00select231140002韓寒男1992-03-23 00:00:00s_noa sname,sex,sbirthday331140003莫言男1997-06-15 00:00:00from student_311400 6159431140004三毛女194-05-30 00:00:00531140005郭敬明1995-12-03 00:00:00(2)、查詢?nèi)w學(xué)生的學(xué)號(hào)、姓名和年齡 實(shí)現(xiàn)代碼及查詢結(jié)果截圖:use sc_3114006159selects_nosnamesex(無(wú)列名s_nof sname,sex,year(getdate()-yea
43、1:31140001 !;.j王小波男19r(sbirthday)231140002韓寒男24from student_3114006159331140003莫言男19431140004三毛女22531140005郭敬明21(3) 、杳詢?cè)合稻幪?hào)為'510000'(計(jì)算機(jī)學(xué)院)的全部學(xué)生的學(xué)號(hào)、姓名、性別和出 身年月日。實(shí)現(xiàn)代碼及查詢結(jié)果截圖:use sc_3114006159select s_no,sname,sex,sbirthday from student_3114006159where dno=16598011$.0011311400010sname sex sbif
44、thday王小波男 1997-01-03 00:00:002 31140002 韓寒 男 1982勺究3 00:00:00(4)、查詢“計(jì)算機(jī)科學(xué)與技術(shù)”專業(yè)(專業(yè)代碼為'080605')并且班級(jí)代碼為'0201' 的學(xué)生的學(xué)號(hào)、姓名和出生日期。實(shí)現(xiàn)代碼及查詢結(jié)果截圖:use sc_3114006159s_nosname sbirthdayselect s_noz sname,sbirthday1 j 31140001 i 王小波 1997«0h3from student_3114006159wherespno=1659801101andclass_n
45、o=114011(5)、查詢?cè)趖983/01/10'以后出生的計(jì)算機(jī)學(xué)院(院系編號(hào)為'510000')學(xué)生的 學(xué)號(hào)、姓名、性別和出身年月日。實(shí)現(xiàn)代碼及查詢結(jié)果截圖:s_no sname sex sbirthday1 rjyuoooi l 王小波 里 1997-01-031use sc_3114006159select s_no,sname,sex,sbirthday from student_3114006159wheredno=16598011 andsbirthday11983-01-101(6)、查詢?nèi)繉W(xué)生的學(xué)號(hào)、姓名、性別和岀身日期結(jié)果按照出生日期的升序排列。
46、 實(shí)現(xiàn)代碼及查詢結(jié)果截圖:use sc_3114006159s_nosnanvesexsbirthdayselect131140002韓寒1982-03-23 (s_no,sname,sex,sbirthdey231140004三毛女19s4-05-30(from student 3114006159331140005郭敬明禺1995-12-03(order by sbirthday431140001王小波1997x)1-03(| 531140003莫言男1997如 5(連接查詢:(1)、查詢?nèi)繉W(xué)生的學(xué)號(hào)、姓名、性別、所在院系名稱和專業(yè)名稱 實(shí)現(xiàn)代碼及査詢結(jié)果截圖:(2)、查詢選修了課程1
47、(上課編號(hào))的學(xué)生的學(xué)號(hào)、姓名、專業(yè)名稱和這門課的成績(jī) 實(shí)現(xiàn)代碼及查詢結(jié)果截圖:use sc_3m4006159selectstudent_3114006159.s_no,sname,spn ame,scorefromstudent_3114006159,student_course _3114 00 6159z speciality_3114 006159 wherestudent_3114006159.s_no=student_c ourse_3114006159s_no andstudent_3114006159.spno=specialit y_3114006159.spno andt
48、cid=ls_nosnatne spnamescorei riiuoooi l王小波 計(jì)茸機(jī)科學(xué)與技術(shù) %(3)、查詢學(xué)生不及格的情況列出不及格學(xué)生的學(xué)號(hào)、姓名和不及格的課程名稱。 實(shí)現(xiàn)代碼及查詢結(jié)果截圖:use sc_3114006159selectstudent_3114006159.s_no,sname,cname fromstudent_3114006159,student_course_3114006159,course_3114006159wherestudent_3114006159.s_no=student_cour se_3114006159s_no and student_
49、course_3114006159tcid=cours e_3114006159.ctno andscore<60s_nosname cname131140002 j韓寒制圖use sc_3114006159selects_nof sname,sex,dept_namef spname fromstudent_3114006159,deparment_3114006159,speciality_3114006159wherestudent_3114006159.dnodeparment_3114006159.dno anddeparment_3114006159dno=specialit
50、 y_3114006159.spname1131140001 1 王小波男計(jì)篇機(jī)計(jì)om學(xué)與財(cái)231140002 韓寒男計(jì)算機(jī)計(jì)算機(jī)科學(xué)與技才331140003 莫言男外國(guó)語(yǔ)商務(wù)英語(yǔ)431140004 三毛女土木土木理531140005郭領(lǐng)明男wi8嵌套査詢:(1)、查詢沒有選修了課程1的學(xué)生,列出學(xué)生的學(xué)號(hào)和姓名。 實(shí)現(xiàn)代碼及查詢結(jié)果截圖:s_nosname1 31140602韓寒2 31?4()()03 莫言3 31140004 三毛4 31140005郭敬明use sc_3114006159select distinctstudent_311
51、4006159.s_no,snamefromstudent_3114006159,student_course_3114006159where student_3114006159.s_no not in (select s_nofrom student_course_3114006159where tcid=l)(2)、查詢每門課都是80分以上的學(xué)生的學(xué)號(hào)與姓名。 實(shí)現(xiàn)代碼及査詢結(jié)果截圖:use sc_3114006159select distinct student_3114006159 . s_no, sname from student_3114006159where not exis
52、ts (select *from student_course_3114006159wherestudent_3114006159s_no=student_course_3114006159.s_no and score<80)s_nosname1 | 31140001 j 王小波2 31140003 莫言3 31140005郭敬明2、選用northwind數(shù)據(jù)庫(kù)進(jìn)行查詢(1)、對(duì)noth wind. products表進(jìn)行簡(jiǎn)單查詢;在查詢分析器在窗口下用select語(yǔ)句 以下部分查詢結(jié)果截圖由于表格過長(zhǎng),所以只截取了部分表格內(nèi)容,無(wú)法完整截圖整個(gè)表格。 完成單表查詢:杳詢所有products的詳細(xì)記錄;實(shí)現(xiàn)代碼及查詢結(jié)果截圖:use north
溫馨提示
- 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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 茶樓承包合同
- 土石方工程開挖施工合同
- 企業(yè)人力資源數(shù)字化轉(zhuǎn)型戰(zhàn)略規(guī)劃設(shè)計(jì)
- 2025年銀川貨運(yùn)車從業(yè)資格證考試內(nèi)容
- 《Scratch初體驗(yàn)》導(dǎo)學(xué)案
- 109-指揮調(diào)度系統(tǒng)
- 節(jié)溫器戰(zhàn)略市場(chǎng)規(guī)劃報(bào)告
- 修路材料采購(gòu)合同范例
- 個(gè)人理財(cái)心得體會(huì)
- 單位施工合同范本
- 兒童服裝設(shè)計(jì)教學(xué)目標(biāo)
- 第07講 兩個(gè)基本計(jì)數(shù)原理(七大題型)(解析版)
- 加油站自動(dòng)化控制系統(tǒng)
- 健康教育知識(shí)講座高血壓
- BLM(含樣例)教學(xué)課件
- 企業(yè)數(shù)字化轉(zhuǎn)型之路燈塔工廠專題報(bào)告
- 低溫恒溫槽日常維護(hù)保養(yǎng)
- 市政道路工程城市道路施工組織設(shè)計(jì)
- 最全食堂菜譜、-公司食堂菜譜大全、-大鍋菜:522道菜+35道湯
- 線下庭審申請(qǐng)書
- ICU護(hù)理查房記錄【范本模板】
評(píng)論
0/150
提交評(píng)論