programing

Oracle 데이터베이스에 존재하는 모든 역할을 나열하는 방법은 무엇입니까?

shortcode 2023. 3. 5. 21:46
반응형

Oracle 데이터베이스에 존재하는 모든 역할을 나열하는 방법은 무엇입니까?

Oracle 데이터베이스에 존재하는 모든 역할을 나열하는 방법은 무엇입니까?

테이블에서 찾고 있습니다.

ROLE_TAB_PRIVS
ROLE_SYS_PRIVS
ROLE_ROLE_PRIVS

SELECT * FROM ROLE_TAB_PRIVS WHERE ROLE = 'ROLETEST';

제가 만든 역할이 없어요.

정답을 찾았습니다.

SELECT * FROM DBA_ROLES;

all_filename을 클릭합니다.sql

SELECT SUBSTR(TRIM(rtp.role),1,12)          AS ROLE
     , SUBSTR(rp.grantee,1,16)              AS GRANTEE
     , SUBSTR(TRIM(rtp.privilege),1,12)     AS PRIVILEGE
     , SUBSTR(TRIM(rtp.owner),1,12)         AS OWNER
     , SUBSTR(TRIM(rtp.table_name),1,28)    AS TABLE_NAME
     , SUBSTR(TRIM(rtp.column_name),1,20)   AS COLUMN_NAME
     , SUBSTR(rtp.common,1,4)               AS COMMON
     , SUBSTR(rtp.grantable,1,4)            AS GRANTABLE
     , SUBSTR(rp.default_role,1,16)         AS DEFAULT_ROLE
     , SUBSTR(rp.admin_option,1,4)          AS ADMIN_OPTION
  FROM role_tab_privs rtp
  LEFT JOIN dba_role_privs rp
    ON (rtp.role = rp.granted_role)
 WHERE ('&1' IS NULL OR UPPER(rtp.role) LIKE UPPER('%&1%'))
   AND ('&2' IS NULL OR UPPER(rp.grantee) LIKE UPPER('%&2%'))
   AND ('&3' IS NULL OR UPPER(rtp.table_name) LIKE UPPER('%&3%'))
   AND ('&4' IS NULL OR UPPER(rtp.owner) LIKE UPPER('%&4%'))
 ORDER BY 1
        , 2
        , 3
        , 4
;

사용.

SQLPLUS> @all_roles '' '' '' '' '' ''
SQLPLUS> @all_roles 'somerol' '' '' '' '' ''
SQLPLUS> @all_roles 'roler' 'username' '' '' '' ''
SQLPLUS> @all_roles '' '' 'part-of-database-package-name' '' '' ''
etc.

언급URL : https://stackoverflow.com/questions/20725581/how-to-list-all-the-roles-existing-in-oracle-database

반응형