A
答案
3、答案:若只是连接数据库,则可以赋予基本的CONNECT角色或CREATE SESSION权限即可,简单的实验如下:
SYS@raclhr> create user lhr identified by lhr;
User created.
SYS@raclhr> conn lhr/lhr
ERROR:
ORA-01045: user LHR lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
@> conn / as sysdba
Connected.
SYS@raclhr> grant connect to lhr;
Grant succeeded.
SYS@raclhr> conn lhr/lhr
Connected.
LHR@raclhr> show user
USER is"LHR"
下面赋予CREATE SESSION权限:
SYS@raclhr> create user lhr2 identified by lhr2;
User created.
SYS@raclhr> conn lhr2/lhr2
ERROR:
ORA-01045: user LHR2 lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
@>
@> conn / as sysdba
Connected.
SYS@raclhr> grant create session to lhr2;
Grant succeeded.
SYS@raclhr> conn lhr2/lhr2
Connected.
LHR2@raclhr>
LHR2@raclhr> select * from dual;
D
-
X
由此可见用户只要被授予CONNECT角色或CREATE SESSION权限即可登录数据库。其实,从Oracle 10g开始,CONNECT角色只保留了CREATE SESSION权限,如下所示:
SYS@raclhr> col ADMIN_OPTION format a12
SYS@raclhr> select * from dba_sys_privs d where d.GRANTEE ='CONNECT' ;
GRANTEE PRIVILEGE ADMIN_OPTION
------------ ----------------- -------------
CONNECT CREATE SESSION NO