CINXE.COM
PostgreSQL: Documentation: 14: 22.5. Predefined Roles
<!doctype html> <html lang="en"> <head> <title>PostgreSQL: Documentation: 14: 22.5. Predefined Roles</title> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8" /> <meta name="theme-color" content="#336791"/> <meta name="copyright" content="The PostgreSQL Global Development Group" /> <meta property="og:url" content="https://www.postgresql.org/docs/14/predefined-roles.html" /> <meta property="og:type" content="article" /> <meta property="article:published_time" content="2024-11-21T14:03:40" /> <meta property="og:image" content="https://www.postgresql.org/media/img/about/press/elephant.png" /> <meta property="og:title" content="22.5. Predefined Roles" /> <meta property="og:description" content="22.5.&nbsp;Predefined Roles PostgreSQL provides a set of predefined roles that provide access to certain, commonly needed, privileged capabilities and information. …" /> <meta property="og:site_name" content="PostgreSQL Documentation" /> <link rel="canonical" href="https://www.postgresql.org/docs/current/predefined-roles.html" /> <link href="/media/css/fontawesome.css?18db9df6" rel="stylesheet"> <link rel="stylesheet" href="/media/css/bootstrap-4.4.1.min.css"> <link rel="shortcut icon" href="/favicon.ico" /> <link rel="stylesheet" type="text/css" href="/dyncss/base.css?18db9df6"> <script src="/media/js/theme.js"></script> </head> <body> <div class="container-fluid"> <div class="row justify-content-md-center"> <div class="col"> <!-- Header --> <nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand p-0" href="/"> <img class="logo" src="/media/img/about/press/elephant.png" alt="PostgreSQL Elephant Logo"> </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#pgNavbar" aria-controls="pgNavbar" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="pgNavbar"> <ul class="navbar-nav mr-auto"> <li class="nav-item p-2"><a href="/" title="Home">Home</a></li> <li class="nav-item p-2"><a href="/about/" title="About">About</a></li> <li class="nav-item p-2"><a href="/download/" title="Download">Download</a></li> <li class="nav-item p-2"><a href="/docs/" title="Documentation">Documentation</a></li> <li class="nav-item p-2"><a href="/community/" title="Community">Community</a></li> <li class="nav-item p-2"><a href="/developer/" title="Developers">Developers</a></li> <li class="nav-item p-2"><a href="/support/" title="Support">Support</a></li> <li class="nav-item p-2"><a href="/about/donate/" title="Donate">Donate</a></li> <li class="nav-item p-2"><a href="/account/" title="Your account">Your account</a></li> </ul> <form role="search" method="get" action="/search/"> <div class="input-group"> <input id="q" name="q" type="text" size="20" maxlength="255" accesskey="s" class="form-control" placeholder="Search for..."> <span class="input-group-btn"> <button class="btn btn-default" type="submit"><i class="fas fa-search"></i></button> </span> </div><!-- /input-group --> </form> <form id="form-theme" class="form-inline d-none"> <button id="btn-theme" class="btn btn-default ml-1" type="button"></button> </form> </div> </nav> </div> </div> <div class="row justify-content-center pg-shout-box"> <div class="col text-white text-center">November 21, 2024: <a href="/about/news/postgresql-172-166-1510-1415-1318-and-1222-released-2965/"> PostgreSQL 17.2, 16.6, 15.10, 14.15, 13.18, and 12.22 Released! </a> </div> </div> </div> <div class="container-fluid margin"> <div class="row"> <div id="pgContentWrap" class="col-11"> <div class="row"> <div class="col-md-6 mb-2"> <div class="row"> <div class="col"> <div> <a href="/docs/" title="Documentation">Documentation</a> → <a href="/docs/14/index.html">PostgreSQL 14</a> </div> </div> </div> <div class="row"> <div class="col"> Supported Versions: <a href="/docs/current/predefined-roles.html" title="PostgreSQL 17 - 22.5. Predefined Roles" >Current</a> (<a href="/docs/17/predefined-roles.html" title="PostgreSQL 17 - 22.5. Predefined Roles" >17</a>) / <a href="/docs/16/predefined-roles.html" title="PostgreSQL 16 - 22.5. Predefined Roles" >16</a> / <a href="/docs/15/predefined-roles.html" title="PostgreSQL 15 - 22.5. Predefined Roles" >15</a> / <a href="/docs/14/predefined-roles.html" title="PostgreSQL 14 - 22.5. Predefined Roles" class="docs-version-selected">14</a> </div> </div> <div class="row"> <div class="col"> Development Versions: <a href="/docs/devel/predefined-roles.html" title="PostgreSQL devel - 22.5. Predefined Roles" rel="nofollow">devel</a> </div> </div> </div> <div class="col-md-6 col-lg-5 offset-lg-1"> <form id="docSearchForm" role="search" method="get" action="/search/"> <input type="hidden" name="u" value="/docs/14/" /> <div class="input-group"> <input type="text" id="q" name="q" class="form-control" placeholder="Search the documentation for..."/> <span class="input-group-btn"> <button class="btn btn-default" type="submit"><i class="fas fa-search"></i></button> </span> </div><!-- /input-group --> </form> </div> </div> <div id="docContent"> <div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="5" align="center">22.5. Predefined Roles</th> </tr> <tr> <td width="10%" align="left"><a accesskey="p" href="role-removal.html" title="22.4. Dropping Roles">Prev</a> </td> <td width="10%" align="left"><a accesskey="u" href="user-manag.html" title="Chapter 22. Database Roles">Up</a></td> <th width="60%" align="center">Chapter 22. Database Roles</th> <td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 14.15 Documentation">Home</a></td> <td width="10%" align="right"> <a accesskey="n" href="perm-functions.html" title="22.6. Function Security">Next</a></td> </tr> </table> <hr /> </div> <div class="sect1" id="PREDEFINED-ROLES"> <div class="titlepage"> <div> <div> <h2 class="title" style="clear: both">22.5. Predefined Roles</h2> </div> </div> </div><a id="id-1.6.9.9.2" class="indexterm" name="id-1.6.9.9.2"></a> <p><span class="productname">PostgreSQL</span> provides a set of predefined roles that provide access to certain, commonly needed, privileged capabilities and information. Administrators (including roles that have the <code class="literal">CREATEROLE</code> privilege) can <code class="command">GRANT</code> these roles to users and/or other roles in their environment, providing those users with access to the specified capabilities and information.</p> <p>The predefined roles are described in <a class="xref" href="predefined-roles.html#PREDEFINED-ROLES-TABLE" title="Table 22.1. Predefined Roles">Table 22.1</a>. Note that the specific permissions for each of the roles may change in the future as additional capabilities are added. Administrators should monitor the release notes for changes.</p> <div class="table" id="PREDEFINED-ROLES-TABLE"> <p class="title"><strong>Table 22.1. Predefined Roles</strong></p> <div class="table-contents"> <table class="table" summary="Predefined Roles" border="1"> <colgroup> <col class="col1" /> <col class="col2" /> </colgroup> <thead> <tr> <th>Role</th> <th>Allowed Access</th> </tr> </thead> <tbody> <tr> <td>pg_read_all_data</td> <td>Read all data (tables, views, sequences), as if having <code class="command">SELECT</code> rights on those objects, and USAGE rights on all schemas, even without having it explicitly. This role does not have the role attribute <code class="literal">BYPASSRLS</code> set. If RLS is being used, an administrator may wish to set <code class="literal">BYPASSRLS</code> on roles which this role is GRANTed to.</td> </tr> <tr> <td>pg_write_all_data</td> <td>Write all data (tables, views, sequences), as if having <code class="command">INSERT</code>, <code class="command">UPDATE</code>, and <code class="command">DELETE</code> rights on those objects, and USAGE rights on all schemas, even without having it explicitly. This role does not have the role attribute <code class="literal">BYPASSRLS</code> set. If RLS is being used, an administrator may wish to set <code class="literal">BYPASSRLS</code> on roles which this role is GRANTed to.</td> </tr> <tr> <td>pg_read_all_settings</td> <td>Read all configuration variables, even those normally visible only to superusers.</td> </tr> <tr> <td>pg_read_all_stats</td> <td>Read all pg_stat_* views and use various statistics related extensions, even those normally visible only to superusers.</td> </tr> <tr> <td>pg_stat_scan_tables</td> <td>Execute monitoring functions that may take <code class="literal">ACCESS SHARE</code> locks on tables, potentially for a long time.</td> </tr> <tr> <td>pg_monitor</td> <td>Read/execute various monitoring views and functions. This role is a member of <code class="literal">pg_read_all_settings</code>, <code class="literal">pg_read_all_stats</code> and <code class="literal">pg_stat_scan_tables</code>.</td> </tr> <tr> <td>pg_database_owner</td> <td>None. Membership consists, implicitly, of the current database owner.</td> </tr> <tr> <td>pg_signal_backend</td> <td>Signal another backend to cancel a query or terminate its session.</td> </tr> <tr> <td>pg_read_server_files</td> <td>Allow reading files from any location the database can access on the server with COPY and other file-access functions.</td> </tr> <tr> <td>pg_write_server_files</td> <td>Allow writing to files in any location the database can access on the server with COPY and other file-access functions.</td> </tr> <tr> <td>pg_execute_server_program</td> <td>Allow executing programs on the database server as the user the database runs as with COPY and other functions which allow executing a server-side program.</td> </tr> </tbody> </table> </div> </div><br class="table-break" /> <p>The <code class="literal">pg_monitor</code>, <code class="literal">pg_read_all_settings</code>, <code class="literal">pg_read_all_stats</code> and <code class="literal">pg_stat_scan_tables</code> roles are intended to allow administrators to easily configure a role for the purpose of monitoring the database server. They grant a set of common privileges allowing the role to read various useful configuration settings, statistics and other system information normally restricted to superusers.</p> <p>The <code class="literal">pg_database_owner</code> role has one implicit, situation-dependent member, namely the owner of the current database. The role conveys no rights at first. Like any role, it can own objects or receive grants of access privileges. Consequently, once <code class="literal">pg_database_owner</code> has rights within a template database, each owner of a database instantiated from that template will exercise those rights. <code class="literal">pg_database_owner</code> cannot be a member of any role, and it cannot have non-implicit members.</p> <p>The <code class="literal">pg_signal_backend</code> role is intended to allow administrators to enable trusted, but non-superuser, roles to send signals to other backends. Currently this role enables sending of signals for canceling a query on another backend or terminating its session. A user granted this role cannot however send signals to a backend owned by a superuser. See <a class="xref" href="functions-admin.html#FUNCTIONS-ADMIN-SIGNAL" title="9.27.2. Server Signaling Functions">Section 9.27.2</a>.</p> <p>The <code class="literal">pg_read_server_files</code>, <code class="literal">pg_write_server_files</code> and <code class="literal">pg_execute_server_program</code> roles are intended to allow administrators to have trusted, but non-superuser, roles which are able to access files and run programs on the database server as the user the database runs as. As these roles are able to access any file on the server file system, they bypass all database-level permission checks when accessing files directly and they could be used to gain superuser-level access, therefore great care should be taken when granting these roles to users.</p> <p>Care should be taken when granting these roles to ensure they are only used where needed and with the understanding that these roles grant access to privileged information.</p> <p>Administrators can grant access to these roles to users using the <a class="link" href="sql-grant.html" title="GRANT"><code class="command">GRANT</code></a> command, for example:</p> <pre class="programlisting"> GRANT pg_signal_backend TO admin_user; </pre> </div> <div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="role-removal.html" title="22.4. Dropping Roles">Prev</a> </td> <td width="20%" align="center"><a accesskey="u" href="user-manag.html" title="Chapter 22. Database Roles">Up</a></td> <td width="40%" align="right"> <a accesskey="n" href="perm-functions.html" title="22.6. Function Security">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">22.4. Dropping Roles </td> <td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 14.15 Documentation">Home</a></td> <td width="40%" align="right" valign="top"> 22.6. Function Security</td> </tr> </table> </div> </div> <div id="docComments"> <h2>Submit correction</h2> <p> If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use <a href="/account/comments/new/14/predefined-roles.html/" rel="nofollow">this form</a> to report a documentation issue. </p> </div> </div> <!-- pgContentWrap --> </div> </div> <!-- Footer --> <footer id="footer"> <div class="container"> <div class="row"> <div class="col-md-12"> <ul> <li><a href="https://twitter.com/postgresql"><img src="/media/img/atpostgresql.png" alt="@postgresql"></a></li> <li><a href="https://git.postgresql.org/gitweb/?p=postgresql.git"><img src="/media/img/git.png" alt="Git"></a></li> </ul> </div> </div> </div> <!-- Copyright --> <div class="container"> <a href="/about/privacypolicy">Privacy Policy</a> | <a href="/about/policies/coc/">Code of Conduct</a> | <a href="/about/">About PostgreSQL</a> | <a href="/about/contact/">Contact</a><br/> <p>Copyright © 1996-2024 The PostgreSQL Global Development Group</p> </div> </footer> <script src="/media/js/jquery-3.4.1.slim.min.js"></script> <script src="/media/js/popper-1.16.0.min.js"></script> <script src="/media/js/bootstrap-4.4.1.min.js"></script> <script src="/media/js/main.js?18db9df6"></script> </body> </html>