需要授予哪些权限才能访问sys.dba_systems

时间:2017-06-14 13:04:13

标签: database oracle schema grant system-tables

我正在开发适用于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()方法

1 个答案:

答案 0 :(得分:4)

使用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
相关问题