【问题标题】:Which permission need to grant to access sys.dba_systems访问 sys.dba_systems 需要授予哪些权限
【发布时间】:2017-11-16 15:47:23
【问题描述】:

我正在开发适用于 Oracle 的应用程序。对于某种逻辑,我需要从具有指定模式的给定 db 用户获取表列表。就我而言,我有一个用户已授予对给定架构的访问权限。因此,当我的代码使用给定凭据创建连接并尝试从以下查询中获取表时,它会返回表列表。

SELECT * FROM dba_objects where owner ='schema' and object_type = 'TABLE'

上述查询与具有授予所有权限的用户一起使用 但是当我在有限的权限下尝试时,它会抛出错误消息。

ORA-00942: table or view does not exist
00942. 00000 -  "table or view does not exist"

对于我们的代码从中创建连接的次要用户已通过以下查询授予权限

create user johnsmith identified by Passw0rd;;
grant connect to johnsmith ;
grant select any table to johnsmith ;
grant UPDATE any table to johnsmith ;
grant DELETE any table to johnsmith ;
grant INSERT any table to johnsmith ;

我应该授予用户哪些权限才能访问以下系统表...?

  • dba_objects
  • user_constraints
  • user_cons_columns
  • USER_TABLES
  • all_tab_cols 并且还允许访问 dbms_metadata.get_dependent_ddl() 方法

【问题讨论】:

    标签: database oracle schema grant system-tables


    【解决方案1】:

    使用the O7_DICTIONARY_ACCESSIBILITY initialisation parameter set to false,这是默认值,那么:

    提供对其他架构中对象的访问权限的系统权限不会授予其他用户访问SYS 架构中对象的权限。例如,SELECT ANY TABLE 权限允许用户访问其他模式中的视图和表,但不允许他们选择字典对象(动态性能视图、常规视图、包和同义词的基表)。但是,您可以授予这些用户显式对象权限以访问 SYS 架构中的对象。

    因此,您可以授予对所需特定视图的选择权限:

    grant select on sys.dba_objects to johnsmith;
    

    其他视图也一样;或者如果你需要他们拥有wider access to the SYS schema objects,你可以给他们一个角色:

    grant select_catalog_role to johnsmith;
    

    虽然principle of least privilege 应该始终适用,所以这可能是矫枉过正,并可能暴露您不希望该用户能够看到的内容。

    您无需为用户授予任何权限即可查询user_* 视图。如果您的意思是那些的 DBA 等价物-例如dba_tables - 然后像上面的dba_objects 一样授予它们;或者他们会被包含在select_catalog_role 中。但同样,只授予实际需要的。

    无论哪种方式,对于dbms_metadata,您也可以只授予该包的权限(您不能授予包中单个过程的权限):

    grant execute on dbms_metadata to johnsmith;
    

    或者 - 可能比实际需要的要多得多,并且可能比选择角色更危险:

    grant execute_catalog_role to johnsmith
    

    【讨论】:

      猜你喜欢
      • 2019-08-23
      • 1970-01-01
      • 1970-01-01
      • 2019-06-24
      • 2018-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-17
      相关资源
      最近更新 更多