当前位置:Gxlcms > 数据库问题 > oracle的用户权限和角色

oracle的用户权限和角色

时间:2021-07-01 10:21:17 帮助过:13人阅读

】  

   ------------------------------

   报错的原因:

     权限的流程:

      system  =》 ken =》 tom

      如何能够赋予他人权限,除system拥有超级权限外,其他用户想要继承赋予他人

      权限的能力,必须在system赋予权限时加入with admin option,才能有赋予权限

      的能力,如上所示在system赋予ken权限时只有创建视图没有加入with adminoption,所以他不能够赋予他人权限,所以报错。

 

 回收系统权限

使用system回收ken [create  session   权限]

基本语法

revoke 权限名称 from 用户名

例:

 revoke create session from ken;

问题:

在回收ken的权限之后,是否也回收曾经是被ken赋予权限的tom的权限。

 答:不是,只回收指定的权限

对象权限

定义:指访问其它方案对象的权利

 

oracle 给我们提供17种对象权限,可以通过如下指令,来查看(dba 角色)

select distinct  privilege from dba_tab_privs;

 

基本语法:

grant 对象权限 on 方案.数据对象 to 用户[with grant option]

grant 对象权限 on 方案.数据对象 to 角色(角色不能拥有赋予权限的权利)

 

案例:

1.monkey用户要操作scott.emp表,则必须赋予相对应的对象权限

 (1)希望monkey可以查询到scott.emp表中的数据?

      使用scott或者system/sys用户操作

     grant select on scott.emp to monkey;

(2)希望monkey可以修改到scott.emp表中的数据?

     grant update on scott.emp to monkey;

(3)希望monkey可以删除到scott.emp表中的数据?

     grant delete on scott.emp to monkey;

(4)有没有简单的方法,一次性赋予所有权利?

     grant all on scott.emp to monkey;

2.授予moneky用户修改scott.emp表的结构 权限

   grant alter on scott.emp to monkey;

3.授予execute权限(概念)

   如果用户想要执行其他方案的包/过程/函数,则需要execute权限。

4.授予monkey用户在scott.emp表中建立索引的权限?

   connect scott/tiger;

   grant index on scott.emp to monkey;

 

回收对象权限:

基本语法:

revoke  对象权限 on 方案.数据对象 from 用户

对象权限是级联回收:因为引用的一个对象,一旦对象消失,就失去了引用。

scott  =>>>>>  blake =>>>>> jones

system操作:

create user blake identified by blake;

create user jones identified by jones;

 

grant create session to blake;

grant create session to jones;

 

使用scott登陆,授予blake查询emp表权限,然后

再用blake授予jones权限,然后查询emp表

 

scott操作

grant select on emp to blake; 

blake操作

grant select on scott.emp to jones;

 

此时,两张表都可查询emp表

 

注意:

scott操作

  revoke select on emp from blake;    --回收权限

此时,两张表都不可查询emp表

 

角色

定义:角色是一组权限的集合,目的是为了简化对权限的管理,从而达到简单的对用户的管理。

角色的分类

  (1)预定义角色:

          oracle提供了33种预定义角色,常用的是(connect,dba,resource);

  ?如何知道某个角色拥有怎样的权限

     select * from dba_sys_privs where grantee = ‘DBA’;

  ?如何知道某个用户拥有什么样的权限

     select * from dba_role_privs where grantee = ‘用户名’;

   注:角色名称一定大写

(2)自定义角色:

     基本语法:

       不带验证:

        create role 角色名 not identified;

               带验证:

                create role 角色名 identified by 密码;
案例:

技术分享

创建角色:

 create role myrole not identified;

 

赋予角色权利:

 系统权限:

 grant create session to myrole;

 对象权限(scott.emp)

 grant select on scott.emp to myrole;

 grant insert on scott.emp to myrole;

 grant update on scott.emp to myrole;

赋予用户角色:

 create user jerry identified by  jerry;

 grant myrole to jerry;

 

回收角色:

drop role mylore;

 

范围:角色既可以包含系统角色,也可以包含自定义角色。

oracle的用户权限和角色

标签:syn   案例   对象权限   建表   消失   connect   sql命令   not   tab   

人气教程排行