LoginSignup
0
0

More than 1 year has passed since last update.

PostgreSQL: デフォルトの権限を確認するSQL

Last updated at Posted at 2021-07-14

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
;

実行結果の例:

CleanShot 2021-07-14 at 10.16.29@2x.png

      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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0