您好,欢迎来到好走旅游网。
搜索
您的当前位置:首页数据库实验四报告

数据库实验四报告

来源:好走旅游网
《数据库原理与应用》实验报告

实验名称: 学 号: 一、实验目的

(1)了解Oracle数据库中的用户管理,模式,权限管理和角色管理。 (2)掌握为用户分配权限的方法。

(3)了解为不同用户分配不同权限的目的及原因。 二、实验过程

1.用系统帐户sys登录数据库,分别创建数据库内部用户user_one和user_two,创建时自己为用户分配帐户口令。 语句:

create user user_one identified by 123456 default tablespace users temporary tablespace temp quota unlimited on users; create user user_two identified by 123456 default tablespace users temporary tablespace temp quota unlimited on users; 执行结果:

班 级: 姓 名:

2.为了使两位用户登录数据库请为其授予相应的权限。 语句:

grant create session to user_one; grant create session to user_two; 执行结果:

3.授予用户user_one在自己模式下创建表的权限,在任何模式下删除表的权限,授予用户user_two可以在任何模式下创建表的权限,查询任何模式下表中数据的权限和在任何模式下创建视图的权限。 语句:

grant create table,drop any table to user_one;

grant create any table,create any view,select any table to user_two; 执行结果:

4.分别用user_one和user_two登录,写出相应的SQL语句验证为其授予的权限。(如果建立的表中有主键约束,需要预先授予user_one和user_two用户create any index的权限。) 语句:

create table t1 (a varchar2(10)); drop table heart.change_major; create table heart.t2(b varchar2(10)); create view heart.abc as

select sc.sno,student.sname,course.cname,grade from student,sc,course

where student.sno=sc.sno and course.cno=sc.cno and major='生物工程';

select sc.sno,student.sname,course.cname,grade from student,sc,course

where student.sno=sc.sno and course.cno=sc.cno and major='生物工程';

执行结果:

5.用系统帐户sys登录数据库,创建用户user_three,将角色权限DBA授予用户user_three,并将S、P、J、SPJ四张表导入到user_three模式下。 语句:

create user user_three

identified by 123456 default tablespace users temporary tablespace temp quota unlimited on users; grant dba to user_three; 执行结果:

6.使用user_three登录,完成如下授权,在user_one和user_two用户下执行相应的SQL语句验证授权是否成功。

(1)把对表S的INSERT权力授予用户user_one,并允许他再将此权限授予其他用户。 语句: grant insert on s to user_one

with grant option; 执行结果:

(2)用户user_two对S,P,J三个表有SELECT和INSERT权力 语句:

grant select,insert on s to user_two; grant select,insert on p to user_two; grant select,insert on j to user_two; 执行结果:

(3)用户user_one对SPJ表有DELETE权力,对QTY字段具有UPDATE权力。

语句:grant delete,update(qty) on spj to user_one; 执行结果:

(4)收回user_one对S表的插入权限。 语句:revoke insert on s from user_one; 执行结果:

7.把对用户user_two授予的所有权限收回,只保留登录权限。(系统权限和对象权限应该分别收回)

语句:revoke create any table,create any view,select any table from user_two; 执行结果:

8.用系统帐户sys登录数据库,创建用户user_four,将角色权限DBA授予此用户,在user_four的模式下导入Sudent、Course和SC表。 语句:

create user user_four identified by 123456 default tablespace users temporary tablespace temp quota unlimited on users;

grant dba to user_four; 执行结果:

9.使用user_four登录,创建角色STUDBA,将修改Student、Course、SC表结构的权限,插入、删除、修改和查询三张表中数据的权限授予角色STUDBA,将角色的权限授予user_one和user_two。 语句:

create role STUDBA;

grant alter,insert,delete,update,select on course to studba; grant alter,insert,delete,update,select on student to studba; grant alter,insert,delete,update,select on sc to studba; grant studba to user_one,user_two; 执行结果:

10.对于通过STUDBA角色授予的权限,在user_one和user_two用户下执行相应的SQL语句对权限进行验证。 语句:

alter table user_four.student add s_entrance date;

select * from student; 执行结果:

三、实验总结

在此次试验中,我通过查询、询问,解决了很多问题。我了解了oracle中授权的基本操作和相关知识。认识到了安全的重要性。 同时以认识到了学习的不足,在以后的学习中要更加努力。

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- haog.cn 版权所有 赣ICP备2024042798号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务