实验名称 数据库的安全性实验 | |||
注意:原版word在下载资源里面(免费下载) | |||
实验目的及要求:
| |||
实验内容及步骤: 1.首先设置能够以“SQL SERVER身份登录”,以Sa登录名进去,密码设置成“sa123” 2.再创建三个以SQL Server身份验证的登录名,登录名分别为login1、login2和login3,密码分别为“111”、“222”和“333” create login login1 with password='111'; create login login2 with password='222'; create login login3 with password='333'; 3.分别为三个登录名在“XSGL”数据库映射三个数据库用户,数据库用户名为Tom,Mary和John,使这三个登录名可以访问“XSGL”数据库。 use XSGL create user Tom for login login1; create user Mary for login login2; create user John for login login3; 4.授予用户John创建表和视图的权限。 grant create table,create view to John; --exec sp_addrolemember 'db_owner',' John' 5.然后以login3登录名进去创建一个新表和一个新的视图进行验证。 创建新表 create table a ( a int); 创建视图 create view b(sno,sname) as select sno,sname from student
grant insert on student to Tom with grant option
grant select,insert on student to Mary grant select,insert on sc to Mary grant select,insert on course to Mary
grant delete on sc to Tom grant update(grade) on sc to Tom
revoke delete,update on sc from Tom revoke insert on student from Tom cascade
新建登录名 create login ddd with password='111' 新建用户 create user u1 for login ddd 新建视图 create view caojing (sno,sname,sdept,grade) as select student.sno,sname,sdept,grade from student,sc where cno in(select cno from course where cname='数据库') grant all on caojing to u1
create login login4 with password='444' create login login5 with password='555' create user u2 for login login4 create user u3 for login login5
create role caojing exec db_datareader'caojing','u2'
create role caojing2 exec db_datawriter'caojing2','u3'
exec sp_helprotect null,'u2' (4)查看SC表的授权信息。 exec sp_helprotect'student' |