개요

내장테이블을 통한 확인

확인 가능 테이블

Check privilege - user중심

schema 확인

select pgu.usename as user_name,
       (select string_agg(scl.schema_name, ',' order by scl.schema_name)
              from information_schema.schemata as scl
              where has_schema_privilege(pgu.usename, scl.schema_name, 'USAGE')) as schema_name
       from pg_user as pgu;

table 확인

-- 1. 
select * from information_schema.role_table_grants 
		where table_schema not in ('pg_catalog', 'information_schema') and grantee = 'user';

-- 2. 
select * from information_schema.table_privileges
		 where table_schema not in ('pg_catalog', 'information_schema');
-- 아래 SQL문을 실행하기 전에 search path를 잘 설정해주어야 한다. 
set search_path to information_schema, [schema1], [schema2], [schema3] ; 

-- 본 SQL문
-- 권한 파트를 수정해서 사용해야 한다. 'SELECT' 파트 
select pgu.usename as user_name,
       (select string_agg(ptb.tablename, ',' order by ptb.tablename)
              from (select * from pg_tables
							where schemaname not in ('pg_catalog', 'information_schema')) as ptb
              where has_table_privilege(pgu.usename, ptb.tablename, 'SELECT')) as table_name
       from pg_user as pgu

Check privilege - object 중심