如何理解Oracle中“通过角色授权”需要用户重新登陆


我们经常听到在Oracle中,通过角色授予用户权限的时候需要用户重新登陆才能获得授予的权限,这句话到底怎么理解呢?通过下面的步骤我们来理解这句话的含义.

1,DBA做如下的操作:

create user u1 identified by u1

create role r1;

grant create session to r1;

grant r1 to u1;

通过查询 select * from dba_sys_privs where grantee='R1',发现权限已经付给了角色.

通过查询 select * from dba_role_privs where grantee='U1',发现角色r1已经付给了用户u1.


2,通过u1登录,能够正常登录,www.bkjia.com查看相应的权限和角色也已经有了.

SQL> show user;
USER is "U1"
SQL> select * from session_privs;

PRIVILEGE
----------------------------------------
CREATE SESSION

SQL> select * from session_roles;

ROLE
------------------------------

R1

3,u1尝试建表:没有建表的权限.

SQL> create table t(i int);
create table t(i int)
*
ERROR at line 1:
ORA-01031: insufficient privileges

4,DBA建立另外一个角色r2,授予r2建表的权限,建r2授予u1.

create role r2;
grant create table to r2;
grant r2 to u1;

通过查询 select * from dba_role_privs where grantee='U1',发现角色r2已经付给了用户u1.

  • 1
  • 2
  • 3
  • 下一页

相关内容