LoginSignup
0
1

More than 1 year has passed since last update.

PostgreSQL: どのカラムにどんな権限があるか確認するSQL

Posted at

PostgreSQLで、どのロールに、どのテーブルのどのカラムに、どんな権限(INSERT, UPDATE, SELECT)が付与されているかを確認するSQLです。

select grantee,
       table_name                                         as "table",
       privilege_type                                     as type,
       string_agg(column_name, ', ' order by column_name) as columns
from information_schema.column_privileges
where table_schema = 'public'
group by grantee, table_name, privilege_type
order by grantee, table_name, privilege_type;

実行結果の例

CleanShot 2021-07-29 at 11.22.05@2x.png

ここで紹介したSQLは「カラム単位」の権限確認です。テーブル単位の大まかな権限の確認方法は次の記事をご覧ください。

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