PostgreSQL : 기본 권한을 확인하는 SQL

PostgreSQL에서 기본 권한 설정이 무엇인지 확인하는 SQL입니다.
SELECT rolname   as owner,
       nspname   as schema,
       case defaclobjtype
           when 'r' then 'table'
           when 'S' then 'sequence'
           when 'f' then 'function'
           when 'T' then 'type'
           when 'n' then 'schema'
           else 'other'
           end   as type,
       defaclacl as access_privileges
FROM pg_default_acl acl
         JOIN pg_namespace ON acl.defaclnamespace = pg_namespace.oid
         JOIN pg_authid on acl.defaclrole = pg_authid.oid
order by owner, schema, type
;

실행 결과의 예:


      rolename=xxxx -- privileges granted to a role
              =xxxx -- privileges granted to PUBLIC

                  r -- SELECT ("read")
                  w -- UPDATE ("write")
                  a -- INSERT ("append")
                  d -- DELETE
                  x -- REFERENCES
                  t -- TRIGGER
                  X -- EXECUTE
                  U -- USAGE
                  C -- CREATE
                  c -- CONNECT
                  T -- TEMPORARY
             arwdxt -- ALL PRIVILEGES (for tables)
                  * -- grant option for preceding privilege

              /yyyy -- role that granted this privilege

좋은 웹페이지 즐겨찾기