{"id":2299,"date":"2025-03-08T12:27:18","date_gmt":"2025-03-08T05:27:18","guid":{"rendered":"https:\/\/www.pgtutorial.com\/?page_id=2299"},"modified":"2025-03-08T15:08:25","modified_gmt":"2025-03-08T08:08:25","slug":"postgresql-create-role","status":"publish","type":"page","link":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/","title":{"rendered":"PostgreSQL CREATE ROLE Statement"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: In this tutorial, you&#8217;ll learn how to create roles with various options using the PostgreSQL\u00a0<code>CREATE ROLE<\/code>\u00a0statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"understanding-postgresql-roles\" id='understanding-postgresql-roles'>Understanding PostgreSQL roles <a href=\"#understanding-postgresql-roles\" class=\"anchor\" id=\"understanding-postgresql-roles\" title=\"Anchor for Understanding PostgreSQL roles\">#<\/a><\/h2>\n\n\n\n<p>In PostgreSQL, a role is an entity that owns database objects such as tables and views. A role has privileges.<\/p>\n\n\n\n<p>A role is like a user in other database systems. Additionally, PostgreSQL uses roles for both users and groups.<\/p>\n\n\n\n<p>Roles act like users if they have the\u00a0<code>LOGIN<\/code>\u00a0privilege. Roles that serve as group (or group role) do not have\u00a0<code>LOGIN<\/code>\u00a0privileges.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"basic-postgresql-create-role-statement\" id='basic-postgresql-create-role-statement'>Basic PostgreSQL CREATE ROLE Statement <a href=\"#basic-postgresql-create-role-statement\" class=\"anchor\" id=\"basic-postgresql-create-role-statement\" title=\"Anchor for Basic PostgreSQL CREATE ROLE Statement\">#<\/a><\/h2>\n\n\n\n<p>You can create a new role using the&nbsp;<code>CREATE ROLE<\/code>&nbsp;statement:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">ROLE<\/span> role_name &#91;<span class=\"hljs-keyword\">WITH<\/span> option1 option2 ...];<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, specify the name of the role after the&nbsp;<code>CREATE ROLE<\/code>&nbsp;keyword.<\/li>\n\n\n\n<li>Second, list the role&#8217;s privileges and attributes in the&nbsp;<code>WITH<\/code>&nbsp;clause.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-a-role-with-login-privilege\" id='creating-a-role-with-login-privilege'>Creating a role with LOGIN privilege <a href=\"#creating-a-role-with-login-privilege\" class=\"anchor\" id=\"creating-a-role-with-login-privilege\" title=\"Anchor for Creating a role with LOGIN privilege\">#<\/a><\/h2>\n\n\n\n<p>The following example uses the&nbsp;<code>CREATE ROLE<\/code>&nbsp;statement to create a role with the&nbsp;<code>LOGIN<\/code>&nbsp;privilege:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">ROLE<\/span> bob\n<span class=\"hljs-keyword\">WITH<\/span> <span class=\"hljs-keyword\">LOGIN<\/span> <span class=\"hljs-keyword\">PASSWORD<\/span> <span class=\"hljs-string\">'securepassword'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>You need to replace the&nbsp;<code>securepassword<\/code>&nbsp;word with your password.<\/p>\n\n\n\n<p>The statement creates a role with the name&nbsp;<code>bob<\/code>&nbsp;that can log in and has a password.<\/p>\n\n\n\n<p>You can use the role&nbsp;<code>bob<\/code>&nbsp;to log in to the PostgreSQL server and connect to the&nbsp;<code>postgres<\/code>&nbsp;database using the&nbsp;<code>psql<\/code>&nbsp;tool as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">psql -U bob -d postgres<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It&#8217;ll prompt you to enter a password for&nbsp;<code>bob<\/code>; use the password you specified when you created the role.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"postgres-superuser\" id='postgres-superuser'>Postgres Superuser <a href=\"#postgres-superuser\" class=\"anchor\" id=\"postgres-superuser\" title=\"Anchor for Postgres Superuser\">#<\/a><\/h2>\n\n\n\n<p>PostgreSQL comes with a default superuser role named&nbsp;<code>postgres<\/code>.<\/p>\n\n\n\n<p>The&nbsp;<code>postgres<\/code>&nbsp;superuser role has full administrative privilege over the entire PostgreSQL server. It means that it can do anything in the database.<\/p>\n\n\n\n<p>The&nbsp;<code>postgres<\/code>&nbsp;superuser bypasses all privilege checks. It can access any database even if it doesn&#8217;t own them.<\/p>\n\n\n\n<p>The&nbsp;<code>postgres<\/code>&nbsp;superuser owns the default database&nbsp;<code>postgres<\/code>.<\/p>\n\n\n\n<p>Typically, you should use the&nbsp;<code>postgres<\/code>&nbsp;superuser for initial setup and maintenance:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Creating other roles.<\/li>\n\n\n\n<li>Managing privileges.<\/li>\n\n\n\n<li>Performing backups and restores.<\/li>\n\n\n\n<li>Installing extensions.<\/li>\n<\/ul>\n\n\n\n<p>It&#8217;s best practice not to use the&nbsp;<code>postgres<\/code>&nbsp;superuser for daily operations. Instead, you should create separate roles with limited privileges and grant only necessary permissions as needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-superuser-roles\" id='creating-superuser-roles'>Creating superuser roles <a href=\"#creating-superuser-roles\" class=\"anchor\" id=\"creating-superuser-roles\" title=\"Anchor for Creating superuser roles\">#<\/a><\/h2>\n\n\n\n<p>The following example creates a superuser role named&nbsp;<code>admin<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">ROLE<\/span> <span class=\"hljs-keyword\">admin<\/span>\n<span class=\"hljs-keyword\">WITH<\/span> <span class=\"hljs-keyword\">LOGIN<\/span> <span class=\"hljs-keyword\">PASSWORD<\/span> <span class=\"hljs-string\">'securepassword'<\/span>\n<span class=\"hljs-keyword\">SUPERUSER<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The&nbsp;<code>admin<\/code>&nbsp;works like the&nbsp;<code>postgres<\/code>&nbsp;superuser role, except you can drop it like a regular role, whereas you cannot drop the&nbsp;<code>postgres<\/code>&nbsp;role.<\/p>\n\n\n\n<p>You create a new superuser role to limit access to the&nbsp;<code>postgres<\/code>&nbsp;role. However, if you only need a superuser role occasionally, use the&nbsp;<code>postgres<\/code>&nbsp;user.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-roles-with-a-validity-period\" id='creating-roles-with-a-validity-period'>Creating roles with a validity period <a href=\"#creating-roles-with-a-validity-period\" class=\"anchor\" id=\"creating-roles-with-a-validity-period\" title=\"Anchor for Creating roles with a validity period\">#<\/a><\/h2>\n\n\n\n<p>When creating a new role, you can use the&nbsp;<code>VALID UNTIL<\/code>&nbsp;option to set the password expiration date.<\/p>\n\n\n\n<p>For example, the following&nbsp;<code>CREATE ROLE<\/code>&nbsp;statement creates a new role with the password expired on March 7, 2025:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">ROLE<\/span> alice\n<span class=\"hljs-keyword\">WITH<\/span> <span class=\"hljs-keyword\">LOGIN<\/span>\n<span class=\"hljs-keyword\">PASSWORD<\/span> <span class=\"hljs-string\">'securepassword'<\/span>\n<span class=\"hljs-keyword\">SUPERUSER<\/span>\n<span class=\"hljs-keyword\">VALID<\/span> <span class=\"hljs-keyword\">UNTIL<\/span> <span class=\"hljs-string\">'2025-03-07'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The password will expire on March 7, 2025. It means that authentication will fail after March 7, 2025.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-roles-with-limited-connections\" id='creating-roles-with-limited-concurrent-connections'>Creating roles with limited concurrent connections <a href=\"#creating-roles-with-limited-concurrent-connections\" class=\"anchor\" id=\"creating-roles-with-limited-concurrent-connections\" title=\"Anchor for Creating roles with limited concurrent connections\">#<\/a><\/h2>\n\n\n\n<p>PostgreSQL allows you to create roles with limited concurrent connections using the&nbsp;<code>CONNECTION LIMIT<\/code>&nbsp;attribute.<\/p>\n\n\n\n<p>For example, the following statement creates a role named&nbsp;<code>api<\/code>&nbsp;with 99 concurrent connections:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">ROLE<\/span> api\n<span class=\"hljs-keyword\">LOGIN<\/span> <span class=\"hljs-keyword\">PASSWORD<\/span> <span class=\"hljs-string\">'securepassword'<\/span>\n<span class=\"hljs-keyword\">CONNECTION<\/span> <span class=\"hljs-keyword\">LIMIT<\/span> <span class=\"hljs-number\">99<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"creating-roles-with-database-creation-privileges\" id='creating-roles-with-database-creation-privileges'>Creating roles with database creation privileges <a href=\"#creating-roles-with-database-creation-privileges\" class=\"anchor\" id=\"creating-roles-with-database-creation-privileges\" title=\"Anchor for Creating roles with database creation privileges\">#<\/a><\/h2>\n\n\n\n<p>When creating a role, you can include privileges such as\u00a0<code>CREATEDB<\/code>. For example, the following statement creates a role called\u00a0<code>dbc<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">ROLE<\/span> dbc\n<span class=\"hljs-keyword\">CREATEDB<\/span>\n<span class=\"hljs-keyword\">LOGIN<\/span> <span class=\"hljs-keyword\">PASSWORD<\/span> <span class=\"hljs-string\">'securepassword'<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The role\u00a0<code>dbc<\/code>\u00a0can log in with a password and <a href=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-database\/\">create new databases<\/a>.<\/p>\n\n\n\n<p>The&nbsp;<code>dbc<\/code>&nbsp;becomes the owner of any database it creates. As the owner, the role&nbsp;<code>dbc<\/code>&nbsp;has complete control over those databases, such as creating tables and modifying data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"displaying-role-attributes\" id='displaying-role-attributes'>Displaying role attributes <a href=\"#displaying-role-attributes\" class=\"anchor\" id=\"displaying-role-attributes\" title=\"Anchor for Displaying role attributes\">#<\/a><\/h2>\n\n\n\n<p>To display attributes of all roles in&nbsp;<code>psql<\/code>, you use the&nbsp;<code>\\du<\/code>&nbsp;command:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">\\du<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\"> Role name |                         Attributes\n-----------+------------------------------------------------------------\n alice     | Superuser                                                 +\n           | Password valid until 2025-03-07 00:00:00-07\n api       | 99 connections\n bob       |\n dbc       | Create DB\n postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS<\/code><\/span><\/pre>\n\n\n<p>The output shows the role name and attributes of each.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"summary\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A role serves as a user that has privileges.<\/li>\n\n\n\n<li>Use the&nbsp;<code>CREATE ROLE<\/code>&nbsp;statement to create a new role.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2299\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL CREATE ROLE Statement\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2299\"\n\t\t\t\tdata-post-url=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/\"\n\t\t\t\tdata-post-title=\"PostgreSQL CREATE ROLE Statement\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn how to create roles with various options using the PostgreSQL\u00a0CREATE ROLE\u00a0statement.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2269,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2299","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PostgreSQL CREATE ROLE Statement<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn how to create roles with various options using the PostgreSQL\u00a0CREATE ROLE\u00a0statement.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PostgreSQL CREATE ROLE Statement\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn how to create roles with various options using the PostgreSQL\u00a0CREATE ROLE\u00a0statement.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/\" \/>\n<meta property=\"og:site_name\" content=\"PostgreSQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-08T08:08:25+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-create-role\\\/\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-create-role\\\/\",\"name\":\"PostgreSQL CREATE ROLE Statement\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\"},\"datePublished\":\"2025-03-08T05:27:18+00:00\",\"dateModified\":\"2025-03-08T08:08:25+00:00\",\"description\":\"In this tutorial, you'll learn how to create roles with various options using the PostgreSQL\u00a0CREATE ROLE\u00a0statement.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-create-role\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-create-role\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/postgresql-create-role\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PostgreSQL Database Administration\",\"item\":\"https:\\\/\\\/www.pgtutorial.com\\\/postgresql-database-administration\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PostgreSQL CREATE ROLE Statement\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pgtutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pgtutorial.com\\\/\",\"name\":\"PostgreSQL Tutorial\",\"description\":\"Learn PostgreSQL from Scratch\",\"alternateName\":\"PostgreSQL\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pgtutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PostgreSQL CREATE ROLE Statement","description":"In this tutorial, you'll learn how to create roles with various options using the PostgreSQL\u00a0CREATE ROLE\u00a0statement.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/","og_locale":"en_US","og_type":"article","og_title":"PostgreSQL CREATE ROLE Statement","og_description":"In this tutorial, you'll learn how to create roles with various options using the PostgreSQL\u00a0CREATE ROLE\u00a0statement.","og_url":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/","og_site_name":"PostgreSQL Tutorial","article_modified_time":"2025-03-08T08:08:25+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/","url":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/","name":"PostgreSQL CREATE ROLE Statement","isPartOf":{"@id":"https:\/\/www.pgtutorial.com\/#website"},"datePublished":"2025-03-08T05:27:18+00:00","dateModified":"2025-03-08T08:08:25+00:00","description":"In this tutorial, you'll learn how to create roles with various options using the PostgreSQL\u00a0CREATE ROLE\u00a0statement.","breadcrumb":{"@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/postgresql-create-role\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pgtutorial.com\/"},{"@type":"ListItem","position":2,"name":"PostgreSQL Database Administration","item":"https:\/\/www.pgtutorial.com\/postgresql-database-administration\/"},{"@type":"ListItem","position":3,"name":"PostgreSQL CREATE ROLE Statement"}]},{"@type":"WebSite","@id":"https:\/\/www.pgtutorial.com\/#website","url":"https:\/\/www.pgtutorial.com\/","name":"PostgreSQL Tutorial","description":"Learn PostgreSQL from Scratch","alternateName":"PostgreSQL","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pgtutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/comments?post=2299"}],"version-history":[{"count":5,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2299\/revisions"}],"predecessor-version":[{"id":2305,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2299\/revisions\/2305"}],"up":[{"embeddable":true,"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/pages\/2269"}],"wp:attachment":[{"href":"https:\/\/www.pgtutorial.com\/wp-json\/wp\/v2\/media?parent=2299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}