2 21.5. Predefined Roles #
4 PostgreSQL provides a set of predefined roles that provide access to
5 certain, commonly needed, privileged capabilities and information.
6 Administrators (including roles that have the CREATEROLE privilege) can
7 GRANT these roles to users and/or other roles in their environment,
8 providing those users with access to the specified capabilities and
9 information. For example:
10 GRANT pg_signal_backend TO admin_user;
14 Care should be taken when granting these roles to ensure they are only
15 used where needed and with the understanding that these roles grant
16 access to privileged information.
18 The predefined roles are described below. Note that the specific
19 permissions for each of the roles may change in the future as
20 additional capabilities are added. Administrators should monitor the
21 release notes for changes.
24 pg_checkpoint allows executing the CHECKPOINT command.
26 pg_create_subscription #
27 pg_create_subscription allows users with CREATE permission on
28 the database to issue CREATE SUBSCRIPTION.
31 pg_database_owner always has exactly one implicit member: the
32 current database owner. It cannot be granted membership in any
33 role, and no role can be granted membership in
34 pg_database_owner. However, like any other role, it can own
35 objects and receive grants of access privileges. Consequently,
36 once pg_database_owner has rights within a template database,
37 each owner of a database instantiated from that template will
38 possess those rights. Initially, this role owns the public
39 schema, so each database owner governs local use of that schema.
42 pg_maintain allows executing VACUUM, ANALYZE, CLUSTER, REFRESH
43 MATERIALIZED VIEW, REINDEX, and LOCK TABLE on all relations, as
44 if having MAINTAIN rights on those objects.
50 These roles are intended to allow administrators to easily
51 configure a role for the purpose of monitoring the database
52 server. They grant a set of common privileges allowing the role
53 to read various useful configuration settings, statistics, and
54 other system information normally restricted to superusers.
56 pg_monitor allows reading/executing various monitoring views and
57 functions. This role is a member of pg_read_all_settings,
58 pg_read_all_stats and pg_stat_scan_tables.
60 pg_read_all_settings allows reading all configuration variables,
61 even those normally visible only to superusers.
63 pg_read_all_stats allows reading all pg_stat_* views and use
64 various statistics related extensions, even those normally
65 visible only to superusers.
67 pg_stat_scan_tables allows executing monitoring functions that
68 may take ACCESS SHARE locks on tables, potentially for a long
69 time (e.g., pgrowlocks(text) in the pgrowlocks extension).
73 pg_read_all_data allows reading all data (tables, views,
74 sequences), as if having SELECT rights on those objects and
75 USAGE rights on all schemas. This role does not bypass row-level
76 security (RLS) policies. If RLS is being used, an administrator
77 may wish to set BYPASSRLS on roles which this role is granted
80 pg_write_all_data allows writing all data (tables, views,
81 sequences), as if having INSERT, UPDATE, and DELETE rights on
82 those objects and USAGE rights on all schemas. This role does
83 not bypass row-level security (RLS) policies. If RLS is being
84 used, an administrator may wish to set BYPASSRLS on roles which
85 this role is granted to.
89 pg_execute_server_program #
90 These roles are intended to allow administrators to have
91 trusted, but non-superuser, roles which are able to access files
92 and run programs on the database server as the user the database
93 runs as. They bypass all database-level permission checks when
94 accessing files directly and they could be used to gain
95 superuser-level access. Therefore, great care should be taken
96 when granting these roles to users.
98 pg_read_server_files allows reading files from any location the
99 database can access on the server using COPY and other
100 file-access functions.
102 pg_write_server_files allows writing to files in any location
103 the database can access on the server using COPY and other
104 file-access functions.
106 pg_execute_server_program allows executing programs on the
107 database server as the user the database runs as using COPY and
108 other functions which allow executing a server-side program.
110 pg_signal_autovacuum_worker #
111 pg_signal_autovacuum_worker allows signaling autovacuum workers
112 to cancel the current table's vacuum or terminate its session.
116 pg_signal_backend allows signaling another backend to cancel a
117 query or terminate its session. Note that this role does not
118 permit signaling backends owned by a superuser. See
121 pg_use_reserved_connections #
122 pg_use_reserved_connections allows use of connection slots
123 reserved via reserved_connections.