resource角色隐式授权unlimited tablespace权限测试

来源:互联网 发布:2017如何开淘宝店铺 编辑:程序博客网 时间:2024/06/04 17:54

由于有需要授权用户resource权限,而这会给用户隐式授予unlimited tablespace 权限,无法控制其表空间使用,

所以测试下先授予resource权限,再回收 unlimited tablespace权限的方式


 --创建测试表空间TEST和测试用户test
SQL> create tablespace TEST datafile '/data/oradata/TEST01.dbf' size 1g;
 
Tablespace created
 
SQL> 
SQL> CREATE USER test
  2    IDENTIFIED BY xxxx
  3    DEFAULT TABLESPACE TEST
  4    TEMPORARY TABLESPACE TEMP
  5    PROFILE DEFAULT
  6    ACCOUNT UNLOCK;
 

User created


--授予连接权限和resource角色权限

SQL>   GRANT CONNECT TO test;
 
Grant succeeded
SQL>  grant RESOURCE to test;
 
Grant succeeded
SQL>   ALTER USER test DEFAULT ROLE ALL;
 
User altered
SQL>   GRANT CREATE SESSION TO test;
 
Grant succeeded




--在其他表空间users创建测试表,有权限
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 
Connected as test
 
SQL> 
SQL> create table test(id number,com varchar2(10)) tablespace users;
 
Table created
SQL> drop table test purge;
 
Table dropped








--收回UNLIMITED TABLESPACE权限
 
SQL> revoke UNLIMITED TABLESPACE from test;
 
Revoke succeeded




--在其他表空间users和默认表空间创建表,均报错,无权限


SQL> create table test(id number,com varchar2(10)) tablespace users;
 
create table test(id number,com varchar2(10)) tablespace users
 
ORA-01950: 对表空间 'USERS' 无权限
 
SQL> create table test(id number,com varchar2(10)) ;
 
create table test(id number,com varchar2(10))
 
ORA-01950: 对表空间 'TEST' 无权限




--给用户单独授予默认表空间的权限
SQL>   alter user test quota  unlimited on  TEST;
 
User altered
 
SQL> 


 
--在默认表空间创建表,有权限。
 
SQL>  create table test(id number,com varchar2(10)) ;
 
Table created
 
SQL> drop table test purge;
 
Table dropped
 
--在其他表空间users创建表,无权限
SQL> create table test(id number,com varchar2(10)) tablespace users;
 
create table test(id number,com varchar2(10)) tablespace users
 
ORA-01950: 对表空间 'USERS' 无权限
 
SQL> 




--结论:
当给用户授予resource角色权限的时候,会隐式的授予unlimited tablespace系统权限。
如果想限制用户的表空间权限,可以回收unlimited tablespace系统权限后,在通过 quota 授予对应的权限。
阅读全文
0 0
原创粉丝点击