【正文】
課程表values(39。739。,39。市場營銷39。,39。6539。,39。339。)insert into 課程表values(39。839。,39。數(shù)據(jù)結(jié)構(gòu)39。,39。7239。,39。339。)insert into 學生選修課表values(39。1000139。,39。139。,39。8039。)insert into 學生選修課表values(39。1000139。,39。239。,39。6839。)insert into 學生選修課表values(39。1000239。,39。239。,39。8539。)insert into 學生選修課表values(39。1000339。,39。339。,39。7639。)insert into 學生選修課表values(39。1000439。,39。639。,39。8739。)insert into 學生選修課表values(39。1000539。,39。539。,39。6039。)insert into 學生選修課表values(39。1000639。,39。739。,39。5839。)insert into 學生選修課表values(39。1000739。,39。439。,39。5439。)insert into 學生選修課表values(39。1000839。,39。839。,39。9039。)insert into 學生德育考評表values(39。1000139。,39。8039。,39。9039。,39。7039。)insert into 學生德育考評表values(39。1000239。,39。8139。,39。8339。,39。8539。)insert into 學生德育考評表values(39。1000339。,39。8839。,39。8039。,39。7539。)insert into 學生德育考評表values(39。1000439。,39。8639。,39。7539。,39。8539。)insert into 學生德育考評表values(39。1000539。,39。8939。,39。8639。,39。8939。)insert into 學生德育考評表values(39。1000639。,39。8339。,39。9039。,39。6139。)insert into 學生德育考評表values(39。1000739。,39。8039。,39。6539。,39。7439。)insert into 學生德育考評表values(39。1000839。,39。9139。,39。8739。,39。9539。)insert into 學生綜合評定情況表values(39。1000139。,39。8039。,39。639。)insert into 學生綜合評定情況表values(39。1000239。,39。8339。,39。339。)insert into 學生綜合評定情況表values(39。1000339。,39。8139。,39。539。)insert into 學生綜合評定情況表values(39。1000439。,39。8239。,39。439。)insert into 學生綜合評定情況表values(39。1000539。,39。8839。,39。239。)insert into 學生綜合評定情況表values(39。1000639。,39。7839。,39。739。)insert into 學生綜合評定情況表values(39。1000739。,39。7339。,39。839。)insert into 學生綜合評定情況表values(39。1000839。,39。9139。,39。139。)select 學號,名次 from 學生綜合評定情況表 where 綜合考評分90select 姓名,學生綜合評定情況表.*,成績 from 學生表, 學生綜合評定情況表,學生選修課表where = and = and 所屬院系=39。商學院39。 and 成績60select * from 學生表where 學號 in (select 學號 from 學生選修課表where 課程號 in (select 課程號 from 課程表where 課程名=39。數(shù)據(jù)庫39。)),max(成績) as 最高成績 from 學生表,學生選修課表 where = group by create view view1asselect as39。學號39。, as39。學生名39。, as39。課程號39。, as39。課程名39。, as39。成績39。from 學生表,課程表,學生選修課表where = and =goupdate view1set 學生名=39。劉瑞瑞39。where 學生名=39。劉瑞39。create proc prc1@課程名 char(20)=39。數(shù)據(jù)庫39。,@avg real outputasbeginif exists (select * from 學生選修課表 where 課程號 in (select 課程號 from 課程表 where 課程名=@課程名 ))select @avg=avg(成績)from 學生選修課表 where 課程號 in (select 課程號 from 課程表 where 課程名=@課程名)elseprint39。無該課程選修記錄39。end declare @課程名1 char(20),@avg1 realset @課程名1=39。數(shù)據(jù)結(jié)構(gòu)39。exec prc1 @課程名1,@avg1 outputcreate trigger trg_delete on 學生表instead of delete asbegin declare @學號 char(12)select @學號=學號 from deletedif exists(select * from 學生選修課表 where 學號=@學號)delete from 學生選修課表 where 學號=@學號elseprint 39。學生選修課表中此人沒選修課39。if exists(select * from 學生德育考評表 where 學號=@學號)delete from 學生德育考評表 where 學號=@學號else print39。學生德育考評表中此人不存在39。if exists(select * from 學生綜合評定情況表 where 學號=@學號)delete from 學生綜合評定情況表 where 學號=@學號elseprint 39。學生綜合評定情況表中此人不存在39。delete from 學生表where 學號=@學號 enddelete from 學生表where 學號=39。1000839。exec sp_addlogin 39。學生39。,39。00039。,39。student39。exec sp_addlogin 39。教師39。,39。00039。,39。student39。exec sp_adduser 39。學生39。 exec sp_adduser 39。教師39。exec sp_addrole 39。管理員39。grant select on 學生表 to 學生with grant optiongrant select on 課程表to 學生with grant optiongrant select on 學生選修課表to 學生with grant optiongrant select on 學生德育考評表to 學生with grant optiongrant select on 學生綜合評定情況表to 學生with grant optiongrant select on 學生表 to 教師with grant optiongrant select on 課程表to 教師with grant optiongrant select,update,insert on 學生選修課表 to 教師with grant optiongrant select,update,insert on 學生德育考評表to 教師with grant optiongrant select,update,insert on 學生綜合評定情況表to 教師with grant optiongrant all on 學生表to 管理員with grant option grant all on 課程表to 管理員with grant option grant all on 學生選修課表to 管理員with grant optiongrant all on 學生德育考評表to 管理員with grant optiongrant all on 學生綜合評定情況表to 管理員with grant optionrevoke select on 學生表from 學生