实验四:用户权限管理实验.doc_第1页
实验四:用户权限管理实验.doc_第2页
实验四:用户权限管理实验.doc_第3页
实验四:用户权限管理实验.doc_第4页
实验四:用户权限管理实验.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实验四:用户权限管理实验一、实验目的掌握SQL Server中有关用户、角色及操作权限的设置方法。二、实验内容1. 用超级用户登录学生数据库student。2. 建立两个新用户:用户名stu1,密码stu1(登录名login1);用户名stu2,密码stu2(登录名login2)和用户名stu3,密码stu3(登录名login3)。3. 授予stu1对SC具有select和insert权限,授予stu1对student具有select,update,insert和delete权限, 授予stu1对Course具有select,update,insert和delete权限。4授予stu2对SC具有select权限,授予stu2对student具有select权限, 授予stu2对Course具有select权限;授予stu2对Course具有更新属性Ccredit的权限。5测试授权以用户Stu1登录学生数据库:(1)查询SC、student和Course表中的所有数据;(2)分别向SC、student和Course表中插入一组合法数据;(3)分别对SC、student和Course表更改一个元组;(4)分别对SC、student和Course表删除一个元组。观察运行结果并分析原因。以用户Stu2登录学生数据库:(1)分别向SC、student和Course表中插入一组合法数据;(2)更新Course表中课程号为1的课程的名称为人工智能;(3)更新Course表中课程号为1的课程的学分为3。观察运行结果并分析原因。以用户Stu1登录学生数据库:(1)收回stu1对SC表的select权限,对student表的update和insert权限,对Course表的delete权限;(2)查询SC、student和Course表中的数据,观察运行结果;(3)分别向SC、student和Course表中插入一组合法数据,观察运行结果;(4)分别对SC、student和Course表更改一个元组,观察运行结果;(5)分别对SC、student和Course表删除一个元组,观察运行结果。思考Course是否具有delete权限执行效果有何不同?6创建数据库角色 Myrole,设置访问student表的select和insert权限,并添加用户成员stu3。以stu3登录查看验证。7使用SQL命令完成:删除登录名login1、login2和login3;删除用户名stu1、stu2和stu3;删除角色Myrole。三、实验学时2学时四、实验设备与环境Windows 2003平台 + SQL Server 2008系统-2. 建立两个新用户:用户名stu1,密码stu1(登录名login1);用户名stu2,密码stu2(登录名login2)和用户名stu3,密码stu3(登录名login3)create login login1 with password =stu1;create User stu1 for login login1;create login login2 with password =stu2;create User stu2 for login login2;create login login3 with password =stu3;create User stu3 for login login3;-3. 授予stu1对SC具有select和insert权限,授予stu1对student具有select,update,insert和delete权限, 授予stu1对Course具有select,update,insert和delete权限grant select,inserton SCto stu1; grant select,update,insert,deleteon studentto stu1;grant select,update,insert,deleteon courseto stu1;-4授予stu2对SC具有select权限,授予stu2对student具有select权限, 授予stu2对Course具有select权限;授予stu2对Course具有更新属性Ccredit的权限grant selecton SCto stu2;grant selecton studentto stu2; grant selecton courseto stu2; grant update(Ccredit)on courseto stu2;-5测试授权-以用户Stu1登录学生数据库:-(1)查询SC、student和Course表中的所有数据;select *from SC;select *from student;select *from course;-(2)分别向SC、student和Course表中插入一组合法数据;insertinto SCvalues(200215123,1,88);insertinto studentvalues(200215124,张三,男,21,CS);insertinto coursevalues(8,大学语文,NULL,3);-(3)分别对SC、student和Course表更改一个元组;update SCset Grade=Grade*0.8;update studentset Sage=Sage+1;update courseset Ccredit=Ccredit+1;-(4)分别对SC、student和Course表删除一个元组。deletefrom SCwhere Cno=1;deletefrom studentwhere (Sdept=CS and Sage20);deletefrom Coursewhere Cname=大学语文;-以用户Stu2登录学生数据库:-(1)分别向SC、student和Course表中插入一组合法数据;insertinto SCvalues(200215123,1,88);insertinto studentvalues(200215124,张三,男,21,CS);insertinto coursevalues(8,大学语文,NULL,3);-(2)更新Course表中课程号为1的课程的名称为人工智能;update courseset Cname=人工智能where Cno=1;-(3)更新Course表中课程号为1的课程的学分为3。update courseset Ccredit=3where Cno=1;-以用户Stu1登录学生数据库:-(1)收回stu1对SC表的select权限,对student表的update和insert权限,对Course表的delete权限;revoke selecton SCfrom stu1;revoke update,inserton studentfrom stu1;revoke deleteon Coursefrom stu1;-(2)查询SC、student和Course表中的数据,观察运行结果;select *from SC;select *from student;select *from course;-(3)分别向SC、student和Course表中插入一组合法数据,观察运行结果;insertinto SCvalues(200215124,5,90);insertinto studentvalues(200215126,李思,男,20,MA);insertinto coursevalues(9,大学体育,NULL,2);-(4)分别对SC、student和Course表更改一个元组,观察运行结果;update SCset Grade=Grade*0.8;update studentset Sage=Sage+1;update courseset Ccredit=Ccredit+1;-(5)分别对SC、student和Course表删除一个元组,观察运行结果。deletefrom SCwhere Cno=2;deletefrom studentwhere Sdept=IS;deletefrom Coursewhere Cname=大学体育;-6创建数据库角色 Myrole,设置访问student表的select和insert权限,并添加用户成员stu3。以stu3登录查看验证。create role Myrole;grant select,inserton studentto Myrole;exec sp_addrolemember Myrole,stu3;select *from student;insertinto studentvalues(20021

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论