본문 바로가기
데이터베이스/PostgreSQL

[PostgreSQL] 모든 테이블 read only User / role 권한 부여

by ordinary_daisy 2024. 8. 16.

개요

  • 모든 테이블에 대해 접근, 조회 권한만 부여된 유저를 전달하기 위함
  • PostgreSQL 14 version 부터 default roles(Predefined Roles) 중에 read_only role이 내장되어 있어서 별도 생성하지 않아도 됨

유저 생성, 권한 부여 예제

  • 8.1 version 부터 User, Group 이 모두 Role로 통합되었으므로, create role로 유저 객체를 생성하는 걸 권장
CREATE ROLE "read_only_user" WITH PASSWORD 'abcde#fgh';

grant pg_read_all_data to read_only_user;

postgresql Predefined Roles 참고

- 표

 

- 출처: https://www.postgresql.org/docs/current/predefined-roles.html