Oracle 谨慎授予用户dba权限

php中文网
发布: 2016-06-07 17:01:03
原创
1553人浏览过

//我们来看下面这个授权的二叉树,实际中肯定是个图(复杂的图): sys / \ test001(dba) test0

//我们来看下面这个授权的二叉树,实际中肯定是个图(复杂的图):  
            sys  
          /     \  
 test001(dba)  test002(dba)  
      /   \          \    
     t1  t2          t3  
--  
//如上二叉树所示,假设test001和test002都被授予了dba权限,  
//test001和test002又各自创建了用户t1,t2,t3;  
//拥有了dba权限的用户,权限是无限大的,就和sys一样的;  
//下面来看一个实例:  
connected as sys  
//创建两个用户test001和test002,并授予dba权限:  
create user test001 identified by test001 default tablespace users;  
grant resource,connect,dba to test001;  
create user test002 identified by test002 default tablespace users;  
grant resource,connect,dba to test002;  
//在test001用户下面创建普通用户t1,t2,并在test001用户下面建立一张表:  
connected as test001  
create user t1 identified by t1;  
grant resource,connect to t1;  
--  
create user t2 identified by t2;  
grant resource,connect to t2;  
--  
create table t_temp(  
       col_1 number(5),  
       col_2 date default sysdate,  
       col_3 varchar2(30));  
--  
insert into t_temp  
select 1001,to_date('2011-01-01','yyyy-mm-dd'),'begin of 2011' from dual union all  
select 1002,to_date('2011-04-30','yyyy-mm-dd'),'end of april' from dual;  
//用户t1登陆,并创建一张表:  
connected as t1  
create table t(  
       id number(2),  
       name varchar2(20),  
       addr varchar2(30));  
insert into t  
select 12,'james','shanghai' from dual union all  
select 13,'thomas','changchun' from dual union all  
select 25,'smith','beijing' from dual;  
//因为test002用户具有dba权限,,那么他就能够访问任何用户下的对象(table,view,procedure...)  
//并且可以任意操作其他用户下的对象:  
connected as test002  
select * from test001.t_temp;  
 col_1 col_2       col_3  
------ ----------- ------------------------------  
  1001 2011-01-01  begin of 2011  
  1002 2011-04-30  end of april  
--  
select * from t1.t;  
 id name                 addr  
--- -------------------- ------------------------------  
 12 james                shanghai  
 13 thomas               changchun  
 25 smith                beijing  
--  
drop table t1.t;  
commit;  
connected as t1  
select * from t1  
ora-00942: table or view does not exist  
--  
connected as test002  
drop table test001.t_temp;  
--  
connected as test001  
select * from t_temp  
ora-00942: table or view does not exist  
//从这里,你可以知道拥有dba权限的用户的权利是多大了吧!  
//所以在实际应用中,一定要谨慎的给予用户dba权限.  
//不具备dba权限的用户,在没有被授权访问的情况下,不能访问其他用户下的对象。  
connected as test002  
grant resource,connect to t3;  
connected as t3  
create table t3_temp(  
       col_1 varchar2(10),  
       col_2 number(5),  
       col_3 varchar2(5));  
--  
select * from t1.t  
ora-00942: table or view does not exist  
drop table t1.t  
ora-00942: table or view does not exist  
//这里并没有提示ora-01031:insufficient privileges,  
//而是告诉当前用户ora-00942: table or view does not exist,  
//其实用户t3并不知道用户t1的存在.  
//但是我们可以通过授权机制,实现不同用户之间的相互访问,  
//前提是该普通用户具有授权的权限  
connected as t1  
grant select on t to t3;  
connected as t3  
select * from t1.t;  
 id name                 addr  
--- -------------------- ------------------------------  
 12 james                shanghai  
 13 thomas               changchun  
 25 smith                beijing 

JoinMC智能客服
JoinMC智能客服

JoinMC智能客服,帮您熬夜加班,7X24小时全天候智能回复用户消息,自动维护媒体主页,全平台渠道集成管理,电商物流平台一键绑定,让您出海轻松无忧!

JoinMC智能客服 193
查看详情 JoinMC智能客服

linux

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号