How to query the permissions on an Oracle directory?

前端 未结 4 1025
遥遥无期
遥遥无期 2021-02-13 06:39

I have a directory in all_directories, but I need to find out what permissions are associated with it, i.e. what has been granted on it?

相关标签:
4条回答
  • 2021-02-13 07:14

    This should give you the roles, users and permissions granted on a directory:

    SELECT * 
      FROM all_tab_privs 
     WHERE table_name = 'your_directory';  --> needs to be upper case
    

    And yes, it IS in the all_TAB_privs view ;-) A better name for that view would be something like "ALL_OBJECT_PRIVS", since it also includes PL/SQL objects and their execute permissions as well.

    0 讨论(0)
  • 2021-02-13 07:19

    With Oracle 11g R2 (at least with 11.2.02) there is a view named datapump_dir_objs.

    SELECT * FROM datapump_dir_objs;
    

    The view shows the NAME of the directory object, the PATH as well as READ and WRITE permissions for the currently connected user. It does not show any directory objects which the current user has no permission to read from or write to, though.

    0 讨论(0)
  • 2021-02-13 07:22

    Wasn't sure if you meant which Oracle users can read\write with the directory or the correlation of the permissions between Oracle Directory Object and the underlying Operating System Directory.

    As DCookie has covered the Oracle side of the fence, the following is taken from the Oracle documentation found here.

    Privileges granted for the directory are created independently of the permissions defined for the operating system directory, and the two may or may not correspond exactly. For example, an error occurs if sample user hr is granted READ privilege on the directory object but the corresponding operating system directory does not have READ permission defined for Oracle Database processes.

    0 讨论(0)
  • 2021-02-13 07:32

    You can see all the privileges for all directories wit the following

    SELECT *
    from all_tab_privs
    where table_name in
      (select directory_name 
       from dba_directories);
    

    The following gives you the sql statements to grant the privileges should you need to backup what you've done or something

    select 'Grant '||privilege||' on directory '||table_schema||'.'||table_name||' to '||grantee 
    from all_tab_privs 
    where table_name in (select directory_name from dba_directories);
    
    0 讨论(0)
提交回复
热议问题