oldwain随便写 http://oldwain.itpub.net/ <a href="http://oldwain.itpub.net">oldwain随便写</a>

itpub论坛回复: 授权何时生效

上一篇 / 下一篇  2006-05-21 00:00:00 / 个人分类:Oracle

问题: 来源(tiansmart )

在oracle9i中,当通过角色为某个用户赋权时,如果用户正处于连接状态,能否实时生效?

我的回答:

ITPUB个人空间(y]j0V yaj7|?\3T


'{.?SY py)] @e0 权限是实时起作用的,role要在重新登陆后起作用

测试:

先看权限的情况ITPUB个人空间 SK.ad.dMR:B!wN)\}
session1:

system@O9I.US.ORACLE.COM> create user testpriv identified by testpriv;

用户已创建

system@O9I.US.ORACLE.COM> grant connect, resource to testpriv;

授权成功。
$C'y#p YJ9bB2NY0

ITPUB个人空间.o;H9y3B6lk8{
session2:
Y-C-fFT%s0
ITPUB个人空间'j Fb_[,A,t!I2qi
scott@O9I.US.ORACLE.COM> connect testpriv/testprivITPUB个人空间&h{8eQ;T0P C8T
已连接。
DRV5V%M+W0 scott@O9I.US.ORACLE.COM> select count(*) from scott.emp;
_`YE)W0 select count(*) from scott.emp
)im7W d&A H0 *
ME Ys0{{X;[0 ERROR 位于第 1 行:ITPUB个人空间mw(mlt$cl oh`Y
ORA-00942: 表或视图不存在
X[B0q G6BO0

session1:


Hv%AW5_eh)bA,t0 system@O9I.US.ORACLE.COM> grant select on scott.emp to testpriv;

授权成功。ITPUB个人空间GI$T&AfI_%fIr

session2:

ITPUB个人空间BlsE!S6z
scott@O9I.US.ORACLE.COM> select count(*) from scott.emp;

COUNT(*)ITPUB个人空间 \o,?5s.JZH
----------ITPUB个人空间yp?9~&P!Xd
14ITPUB个人空间#cm+r{/bK@A

session1:


yNZ'vNr'Czw5e0 system@O9I.US.ORACLE.COM> revoke select on scott.emp from testpriv;

撤销成功。ITPUB个人空间` U:n,y y;G[1E

session2:


:mm |Z(~3S#Oa T0 scott@O9I.US.ORACLE.COM> select count(*) from scott.emp;
br(mqN9gc0 select count(*) from scott.emp
|xn OJ7c0 *ITPUB个人空间n\cM:O%C ~
ERROR 位于第 1 行:
/N^pE/}0 ORA-00942: 表或视图不存在
W5NB&@?7s"d0

可见直接授权是立即生效的, 不需要用户重新登陆.ITPUB个人空间 p8s/oojX:Qb
下面看看通过角色授权的情况:ITPUB个人空间TUd'd)QZ@
session1:


.YL(C)}2t#V;Fe.s'L ?o0 system@O9I.US.ORACLE.COM> create role testprivrole;

角色已创建

system@O9I.US.ORACLE.COM> grant select on scott.emp to testprivrole;

授权成功。

system@O9I.US.ORACLE.COM> grant testprivrole to testpriv;

授权成功。
V N)jKN0

session2:

ITPUB个人空间6Jd3Z'sv,rv:X
scott@O9I.US.ORACLE.COM> select count(*) from scott.emp;
$H(y"C,a&~p Wp L0 select count(*) from scott.emp
L YzKi,_R%hP0 *
wga-_U$x6p0 ERROR 位于第 1 行:ITPUB个人空间,[ _.].v^R^7JzO
ORA-00942: 表或视图不存在ITPUB个人空间9KC dG5Y\R"u:ab#L?
ITPUB个人空间 yg4c/rp1BA.R$L
可见,通过角色授权并未立即生效, 我们将session2断开重新登陆

ITPUB个人空间"\LX(g#\
scott@O9I.US.ORACLE.COM> disconnect
I.p(zO'BJn:W0 从Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
9^:P[-VY YX)L,Z^i|7~!]0 With the Partitioning, OLAP and Oracle Data Mining options
O Qc$i5T0 JServer Release 9.2.0.4.0 - Production中断开
X/U*I(C.Z3XT0 system@O9I.US.ORACLE.COM> connect testpriv/testpriv
wB} n2p0 已连接。ITPUB个人空间2o#TUBa
scott@O9I.US.ORACLE.COM> select count(*) from scott.emp;

COUNT(*)
&C~e)p'V'i*C0 ----------
W4k Hv[ L*`Be0 14
Y"|#Z%v+N&A0

重新登陆后,通过角色授权生效了, 那么撤销授权呢?
Dw{:n3h@0 session1:

ITPUB个人空间mT,v,zrs
system@O9I.US.ORACLE.COM> revoke testprivrole from testpriv;

撤销成功。
S!~;PS Pz*a%?H n0

ITPUB个人空间;D6Kx1F#vn
session2:ITPUB个人空间 Exgm%DgHd
ITPUB个人空间K
J b&u~
p'K
scott@O9I.US.ORACLE.COM> select count(*) from scott.emp;

COUNT(*)ITPUB个人空间s$l{5v[ x1?3P"S
----------ITPUB个人空间P(vj,l t~^
14ITPUB个人空间7lob"ey L5P


m&f;SY E!o o-L'@ l0 可见,即使是撤销角色,也要等到下次登陆才能生效。

再来看看,如果撤销对角色的授权的情况:

session1:


5o}QJy iu0 system@O9I.US.ORACLE.COM> revoke select on scott.emp from testprivrole;

撤销成功。

session2:

ITPUB个人空间&{'lv!ZiBRc
scott@O9I.US.ORACLE.COM> select count(*) from scott.emp;
9QN@_ VFL0 select count(*) from scott.empITPUB个人空间8h6HegGf"{#M{c
*ITPUB个人空间 R.Lb1u#L8z,Y
ERROR 位于第 1 行:ITPUB个人空间4L `ePX,Uz
ORA-00942: 表或视图不存在
/K ^Tku([&@FN m?0

0Ub)Uc i"f!kzr0 结论: 授予权限(privileges)总是立即生效的(无论授予用户还是角色),给用户授予角色要等到下次登陆才能生效。

Technorati Tags: , ,

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-11-23  
      1
2345678
9101112131415
16171819202122
23242526272829
30      

数据统计

  • 访问量: 2741
  • 日志数: 1042
  • 建立时间: 2007-11-28
  • 更新时间: 2008-02-22

RSS订阅

Open Toolbar