您的位置:首页 > 数据库

数据库实验四(用户权限管理 )

2017-06-04 20:44 477 查看
1. 用 SYSTEM 账户登录数据库,创建用户 A、B、C,密码分别为 A、B、C;

create user A identified by A;
create user B identified by B;
create user C identified by C;

2. 用 SYSTEM 账户把 CREATE SESSION 和 CREATE TABLE 权限授予给用户 A,并 允许用户 A 传递获得的权限;使用以下的 ALTER USER 命令修改用户 A 的默认表空 间为 users,使用户 A 能在 student 中插入数据;

alter user A default tablespace users quota unlimited on users;
grant create session,create table to A with admin option;

3. 用户 A 连接登录数据库,创建关系模式 student(sno,sname,sage)(自定义属性的数据类 型),用户 A 向表 student 插入数据(插入内容自定义),并执行 commit 提交数据;

create table student
(
sno char(12) primary key,
sname char(10) not null,
sage int
);

insert into student(sno,sname,sage) values('10001','冷冷',18);
insert into student(sno,sname,sage) values('10003','dd',18);
commit;

4. 用户 A 把 CREATE SESSION、对表 student 的 select 和 Insert 权限授予给 B,并允许 B 传递获得的权限,然后使用用户 B 登录数据库测试用户 B 获取的权限;

grant create session to B with admin option;
grant select,insert on student to B with grant option;
select * from A.student;

5. 用户 B 把 CREATE SESSION、对表 student 的 select 权限授予给用户 C;

grant create session to C;
grant select on A.student to C;

6. 用户 C 登录数据库,测试获得的权限;

select * from A.student;

7. 用户 A 把 student 的属性 sname、age 的修改权限授予用户 B;

grant update(sname,sage) on student to B;

8. 用户 A 收回用户 B 对 student 表的 select 权限,测试用户 B、C 是否仍然具有对 student 表的 select 权限;

revoke select on student from B;

select * from a.student;

9. 用户 A 回收用户 B 的 CREATE SESSION 权限,测试用户 B、C 是否仍然可以连接登 录到数据库;

revoke create session from B;

10. 由系统管理员授予用户 A 创建角色的权限;
great create role to a;

11. 用户 A 创建角色 MyRole,授予角色 MyRole 对表 Student 的 select 权限以及 CREATE SESSION 权限;

create role myrole;
grant select on student to myrole;
grant create session to myrole;

12. 用户 A 把角色 MyRole 授予给用户 B,并允许用户 B 对角色进行管理,测试用户 B 获 取的权限;

grant myrole to B with admin option;
select * from A.student;

13. 用户 B 把角色 MyRole 授予给用户 C,测试用户 C 是否具有对 Student 表的 select 权 限;

grant myrole to C with admin option;

select * from A.student;

14. 用户 A 回收用户 B 的 MyRole 角色权限,测试 B、C 拥有的对 Student 表的 select 权 限是否已经回收;

revoke myrole from B;
select * from A.student;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: