这个问题,经常遇到有人问,我的表被人修改了,那么哪些人可以访问这个表呢,能否进行查询,答案是肯定的,我们可以使用数据字典来进行查询:
比如,我们想查看哪些人有权访问departments表:
1.创建用户
sql>conn / as sysdba;
sql> create user zq identified by zq;
sql> grant connect to zq;
sql> create user sztech identified by sztech; sql> grant connect to sztech; 2.授权给zq带grant option
sql>conn hr/hr;
sql>grant select on departments to zq with grant option;
3.zq授权给sztech
sql>conn zq/zq
sql> grant select on departments to sztech;
4.检查departments表哪些用户可以访问
sql>conn hr/hr;
sql>
select lpad(grantee,length(grantee)+2*(level-1),'_') as grantee from user_tab_privs_made where table_name='DEPARTMENTS' start with grantor='HR' CONNECT BY PRIOR grantee=grantor;
以上语句,我们使用了分层查询语句,把传递授权都可以直观的显示出来.
GRANTEE -------------------------------------------------------------------------------- OE R_AUTH ZQ __SZTECH
|