按题意,操作如下:
1、创建一个角色r1
sys@OCM> create role r1;
Role created.
2、角色r1可以查询和插入oe用户下的orders表
sys@OCM> grant select,insert on oe.orders to r1;
Grant succeeded.
3、把r1拥有的所有全权授权给scott用户
sys@OCM> grant r1 to scott;
Grant succeeded.
4、授予scott用户可以查oe用户下的orders表的权限
sys@OCM> grant select on oe.orders to scott;
Grant succeeded.
5、回收查oe用户下的orders表的权限
sys@OCM> revoke select on oe.orders from scott;
Revoke succeeded.
6、scott用户登录询查oe用户下的orders表
sys@OCM> conn scott/scott
Connected.scott@OCM> select * from oe.orders;
ORDER_IDORDER_DATE ORDER_MO CUSTOMER_ID ORDER_STATUS ORDER_TOTAL SALES_REP_ID PROMOTION_ID
--------------------------------------------------------------------------------------------- ----------- ------------ ----------- ------------ ------------
245817-AUG-07 05.34.12.234359 AM direct 101 0 78279.6 153
239720-NOV-07 06.41.54.696211 AM direct 102 1 42283.2 154
direct 105 2 7826 155
。。。。。。。。。。。省略。。。。。。。。。。。。。。。。。。。
245118-DEC-07 09.03.52.562632 AM direct 148 7 10474.6 154
direct 117 0 3878.4 163
245701-NOV-07 01.22.16.162632 PM direct 118 5 21586.2 159
105 rows selected.
用revoke命令回收了scott用户查oe用户下的orders表,但
Scott用户还是可以查出oe用户中的orders表记录。这是什么回事呢?
我们先来看角色r1的对象权限:
sys@OCM> select * from dba_tab_privs where grantee='R1';
GRANTEE OWNER TABLE_NAME GRANTOR PRIVILEGE GRA HIE
------------------------------------------------------------ ------------------------------------------------------------ ---------------------------------------- --- ---
R1 OE ORDERS OE SELECT NO NO