第一范文网 - 专业文章范例文档资料分享平台

《SQL - Server - 2000 - 实验指导》课后作业

来源:用户分享 时间:2025/6/6 11:42:36 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

- 36 -

5、创建一个角色newstudent,使其具有对数据库jiaoxuedb进行任何操作的权限。并将上面创建的用户:newuser、sqladmin、sqlteacher添加到此用户中。

- 37 -

- 38 -

实验13:习题

1、编写一个事务:对于考试违纪的学生,对其采取考试成绩降一个档次的处罚。考试成绩分为5档次:优、良、中、及格、不及格。 begin transaction use jiaoxuedb go

select sno,cno,grade=

case when score<60 then '不及格'

when score<70 and score>=60 then '及格' when score<80 and score>=70 then '中等' when score<90 and score>=80 then '良好' when score>=90 and score<=100 then '优秀' end

from sc where flag=0 union

select sno,cno,grade=

case when score-10<60 then '不及格'

when score-10<70 and score>=60 then '及格' when score-10<80 and score>=70 then '中等' when score-10<90 and score>=80 then '良好' end

from sc where flag=1 commit

2.对于发生教学事故的教师要进行罚款处理,假如用x表示罚款数额。编写一个罚款事务,要求:从被罚款的教师工资中扣除罚款额x,若工资额大于等于罚款额x,则提交罚款,否则,扣除工资的一半作为罚款额,剩余罚款额以后再扣除,并修改显示剩余的罚款额x。 begin transaction use jiaoxuedb declare @pay int,@name char(10),@sal int set @pay=1000 set @name='李英' select @sal=sal from teacher where tn=@name if @sal>@pay begin update teacher set sal=sal-@pay where tn=@name select @sal=sal from teacher where tn=@name print @name+'经过处罚后还剩余的工资为:'+str(@sal) commit end else begin update teacher set sal=sal-sal/2 where tn=@name - 39 -

select @pay=@pay-sal from teacher where tn=@name print @name+'还欠款'+str(@pay) end go 3.完成下面事务设计:某高校嘉奖优秀教师:增加津贴500元;若此教师为助教,则可破格将其晋升为讲师。获得优秀教师的条件是:至少任两门课课程,并且每门课程的及格率100%,优秀率33%。 4.设计一个事务,给所有在册的非新生学生增加1岁,要求,50人作为一个事务提交一次。

- 40 -

搜索更多关于: 《SQL - Server - 2000 - 实验指导》课后 的文档
《SQL - Server - 2000 - 实验指导》课后作业.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1jbe103h3q2cg5h8iuau_10.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top