实验理解ADMIN OPTION和GRANT OPTION的用法

使用GRANT赋予用户权限的时候通常有ADMIN OPTION和GRANT OPTION这两个OPTION。下面使用简单的实验来体会下这两种授权的用途。


一、ADMIN OPTION参数

实验:

1. 创建测试用户user_a和user_b

Center


2. 默认情况下,user_a和user_b是没有建表权限

Center


3. SYS账户GRANT CREATE TABLE权限给user_a,但user_a则是没有权限授予user_b建表权限

Center


4. SYS账户GRANT CREATE TABLE权限给user_a,同时带上WITH ADMIN OPTION,此时user_a可以授予user_b建表权限

Center


5. SYS账户收回user_a的CREATE TABLE权限

Center


6. 此时user_b仍可具有CREATE TABLE权限,尽管这里报错

Center

注:这个错是说user_b没有默认表空间USERS的使用权限,并不是没有建表权限,此时需要SYS账户使用GRANT UNLIMITED TABLESPACE TO user_b或ALTER USER user_b quota 100m on USERS让user_b用户可以使用USERS表空间

Center


总结

1. 带有WITH ADMIN OPTION的权限授予方式,可传递授权。

2. 带有WITH ADMIN OPTION的权限授予方式,当使用REVOKE收回权限时,传递的授权并不会自动收回。

3. ADMIN OPTION用于系统权限,system privilege,例如CREATE TABLE。


二、GRANT OPTION

实验:

1. 授予user_a和user_b创建session的权限,但用user_a查询dcsopen的t1表时提示无此权限

Center


2. SYS账户使用WITH GRANT OPTION授予user_a查询dcsopen.t1表权限

Center

此时user_a可以查询表:

Center


3. 使用user_a授予user_b查询dcsopen.t1表权限

Center


4. SYS账户收回user_a的查询dcsopen.t1表的权限

Center


5. 使用user_b用户查询dcsopen.t1表时提示无权限

Center


总结

1. 使用WITH GRANT OPTION的权限授予方式,可传递授权。

2. 使用WITH GRANT OPTION的权限授予方式,当使用REVOKE收回权限时,传递的授权会自动收回。

3. GRANT OPTION用于对象权限,object privilege,例如SELECT ON TABLE。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7192724/viewspace-1344019/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7192724/viewspace-1344019/

CREATE USER cedar IDENTIFIED BY cedar DEFAULT TABLESPACE CEDAR_DATA TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; -- 5 Roles for cedar GRANT DBA TO cedar; GRANT RESOURCE TO cedar WITH ADMIN OPTION; GRANT AQ_ADMINISTRATOR_ROLE TO cedar; GRANT CONNECT TO cedar WITH ADMIN OPTION; GRANT AQ_USER_ROLE TO cedar; ALTER USER cedar DEFAULT ROLE ALL; -- 44 System Privileges for cedar GRANT CREATE ANY DIRECTORY TO cedar WITH ADMIN OPTION; GRANT CREATE PUBLIC SYNONYM TO cedar WITH ADMIN OPTION; GRANT EXECUTE ANY CLASS TO cedar WITH ADMIN OPTION; GRANT DROP ANY VIEW TO cedar WITH ADMIN OPTION; GRANT CREATE CLUSTER TO cedar; GRANT ALTER SYSTEM TO cedar; GRANT UPDATE ANY TABLE TO cedar; GRANT INSERT ANY TABLE TO cedar; GRANT LOCK ANY TABLE TO cedar; GRANT CREATE EXTERNAL JOB TO cedar WITH ADMIN OPTION; GRANT EXECUTE ANY PROGRAM TO cedar WITH ADMIN OPTION; GRANT CREATE JOB TO cedar WITH ADMIN OPTION; GRANT DROP ANY DIRECTORY TO cedar WITH ADMIN OPTION; GRANT ALTER ANY TRIGGER TO cedar; GRANT CREATE DATABASE LINK TO cedar; GRANT DROP ANY TABLE TO cedar WITH ADMIN OPTION; GRANT CREATE TABLE TO cedar WITH ADMIN OPTION; GRANT QUERY REWRITE TO cedar; GRANT ANALYZE ANY TO cedar; GRANT DROP ANY TRIGGER TO cedar; GRANT EXECUTE ANY PROCEDURE TO cedar; GRANT SELECT ANY TABLE TO cedar WITH ADMIN OPTION; GRANT ALTER ANY TABLE TO cedar; GRANT UNLIMITED TABLESPACE TO cedar WITH ADMIN OPTION; GRANT CREATE SESSION TO cedar; GRANT CREATE ANY TRIGGER TO cedar; GRANT DROP ANY PROCEDURE TO cedar WITH ADMIN OPTION; GRANT ALTER ANY PROCEDURE TO cedar; GRANT DROP PUBLIC SYNONYM TO cedar WITH ADMIN OPTION; GRANT DROP ANY SYNONYM TO cedar WITH ADMIN OPTION; GRANT MANAGE SCHEDULER TO cedar WITH ADMIN OPTION; GRANT CREATE ANY PROCEDURE TO cedar; GRANT CREATE PROCEDURE TO cedar WITH ADMIN OPTION; GRANT CREATE SEQUENCE TO cedar; GRANT CREATE VIEW TO cedar WITH ADMIN OPTION; GRANT CREATE SYNONYM TO cedar; GRANT DROP ANY INDEX TO cedar; GRANT DELETE ANY TABLE TO cedar; GRANT CREATE ANY TABLE TO cedar; GRANT CREATE ANY JOB TO cedar WITH ADMIN OPTION; GRANT SELECT ANY DICTIONARY TO cedar WITH ADMIN OPTION; GRANT CREATE ROLE TO cedar; GRANT CREATE ANY SYNONYM TO cedar WITH ADMIN OPTION; GRANT ALTER SESSION TO cedar WITH ADMIN OPTION; GRANT EXECUTE ON sys.dbms_aq TO cedar; GRANT EXECUTE ON sys.dbms_aqadm TO cedar; GRANT EXECUTE ON sys.dbms_network_acl_admin TO cedar; GRANT ALL ON sys.DBMS_LOCK TO cedar; 这个SQL在oracle 能用吗
最新发布
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值