【文章內容簡介】
re values(39。10139。,39。0239。,85) insert into score values(39。10239。,39。0239。,80) insert into score values(39。10139。,39。0339。,88) insert into score values(39。10239。,39。0239。,85) insert into score values(39。10239。,39。0339。,80) insert into score values(39。10339。,39。0139。,83) insert into score values(39。10339。,39。0239。,85) insert into score values(39。10339。,39。0339。,90) insert into score values(39。10439。,39。0139。,60) ???? 查看記錄 Select * from score ( 3)、向教師表中添加數據 insert into course values(39。0139。,39。計算機 39。,39。1139。) insert into course values(39。0239。,39。網絡管理 39。,39。1239。) insert into course values(39。0339。,39。專業(yè)英語 39。,39。1339。) insert into course values(39。0439。,39。軟件工程 39。,39。1439。) ???? 查看記錄 Select * from course ( 4)、向課程表中添加數據 insert into teacher values(39。1139。,39。無意 39。,39。計算機系 39。,39。男 39。,39。19734539。,39。教授 39。) insert into teacher values(39。1239。,39。生活 39。,39。計算機系 39。,39。女 39。,39。197512139。,39。副教授 39。) insert into teacher values(39。1339。,39。沒有 39。,39。管理系 39。,39。女 39。,39。19753339。,39。副教授 39。) insert into teacher values(39。1439。,39。離開 39。,39。英語系 39。,39。男 39。,39。19735539。,39。教授 39。) ???? 查看記錄 Select * from teacher 一些查詢語句 ( 1)、查詢成績大于學號為 101 的學生的課程為 02 的成 績的所有列。 select * from score where degree(select degree from score where sno=39。10139。 and o=39。0239。) ( 2)、查詢課程號 01 大于課程號 02 的最大值、并以分數降序排序的成績表中所有列 select * from score s where =39。0139。 and =(select max(degree) from score y where =39。0239。 ) order by degree desc go select max(degree) as 02max from score where o=39。0239。 (3)、查詢性別為男的學號,姓名,班級,課程號和成績的學生 select , from student,score where = and ssex=39。男 39。 (4)、查詢成績在 60 到 80 之間的所有列 select * from score where degree between 60 and 80 (5)、查詢 score 表中至少有 5 名學生選修的并以 0 開頭的課程的平均分 select avg(degree) as 平均分 ,o from score where o like 39。0%39。 group by o having count(*)=5 創(chuàng)建自定義數據類型 創(chuàng)建一個 自定義數據類型 exec sp_addtype , 39。varchar(20)39。 , 39。null39。 修改 student 表中的 s 數據類型為 類型 alter table student alter column s 向表中添加字段 向 student 表添加 type,s,b 并且郵件地址有 check 約束 alter table student add type char(7) alter table student add s varchar(20) null constraint ck_sem check (s like 39。%@%39。) alter table teacher add tel varchar(15) 創(chuàng)建視圖 ( 1)、創(chuàng)建所有 11 班的學生信息的視圖 create view student11 as select * from student where class=39。1139。 查看視圖中的記錄 select * from student11 ( 2)、創(chuàng)建視圖 course_degree,其中的內容是選修計算機課程的學生信息,包括( sno,sname,o,ame,degree),創(chuàng)建時加上 with check option create view course_degree(sno,sname,o,ame,degree) as select ,sname,ame,degree from course ,student, score where = and = and ame=39。計算機 39。 with check option 查看視圖中的記錄 select * from course_degree ( 3)、創(chuàng)建一個視圖,其中的內容是成績表中每門課程的 create view average as select avg(degree) as 39。平均分 39。 from score group by o 查看視圖中的記錄 select * from average ( 4)、創(chuàng)建視圖其中的內容是所有男教師和男學生的 name,sex,birth creat