Difference between revisions of "PostgreSQL: CREATE ROLE"

From wikieduonline
Jump to navigation Jump to search
 
(42 intermediate revisions by 2 users not shown)
Line 1: Line 1:
*<code>[[CREATE ROLE]]</code> adds a new role to a [[PostgreSQL]] database [[cluster]]. A role can be considered a [[user]], or [[group]].
+
<code>[[CREATE]] ROLE</code> adds a new [[role]] to a [[PostgreSQL]] database [[cluster]]. A role can be considered a [[user]], or [[group]].
 +
==Overview==
 +
* https://www.postgresql.org/docs/14/sql-createrole.html
 +
CREATE ROLE name [ [ WITH ] option [ ... ] ]
 +
 +
where option can be:
 +
 +
      [[SUPERUSER]] | NOSUPERUSER
 +
    | [[CREATEDB]] | NOCREATEDB
 +
    | CREATEROLE | NOCREATEROLE
 +
    | CREATEUSER | NOCREATEUSER
 +
    | INHERIT | NOINHERIT
 +
    | LOGIN | [[NOLOGIN]]
 +
    | REPLICATION | NOREPLICATION
 +
    | CONNECTION LIMIT connlimit
 +
    | [ [[ENCRYPTED]] | UNENCRYPTED ] PASSWORD 'password'
 +
    | VALID UNTIL 'timestamp'
 +
    | IN ROLE role_name [, ...]
 +
    | IN GROUP role_name [, ...]
 +
    | ROLE role_name [, ...]
 +
    | ADMIN role_name [, ...]
 +
    | USER role_name [, ...]
 +
    | SYSID uid
  
 +
=== Examples ===
 +
* <code>[[CREATE ROLE]] my_username [[WITH LOGIN PASSWORD]] '123456' [[VALID UNTIL]] '2022-01-01';</code>
 +
* <code>CREATE ROLE my_username WITH CREATEDB [[CREATEROLE]]; </code>
 +
* <code>CREATE ROLE my_username [[NOLOGIN]];</code>
  
===Overview===
+
== Related ==
<ref>https://www.postgresql.org/docs/9.2/sql-createrole.html</ref>
+
* <code>[[ALTER USER]]</code>
<pre>CREATE ROLE name [ [ WITH ] option [ ... ] ]
+
* <code>[[PostgreSQL: CREATE USER]]</code>
 +
* [[PostgreSQL: Database roles]]
 +
* <code>[[GRANT]] your_username_origin TO your_new_username_with_same_privileges;</code>
 +
* <code>[[useradd]]</code>
 +
* [[List users]]: <code>[[\du]]</code>
 +
* [[ERROR: role "your role" does not exist]]
 +
* [[EOF]]
 +
* [[PostgreSQL users]]
 +
* [[ERROR: permission denied to create role]]
  
where option can be:
+
== See also ==
 +
* {{create role}}
 +
* {{Role}}
 +
* {{CREATE}}
  
      SUPERUSER | NOSUPERUSER
+
[[Category: PosgreSQL]]
    | CREATEDB | NOCREATEDB
+
[[Category: SQL]]
    | CREATEROLE | NOCREATEROLE
 
    | CREATEUSER | NOCREATEUSER
 
    | INHERIT | NOINHERIT
 
    | LOGIN | NOLOGIN
 
    | REPLICATION | NOREPLICATION
 
    | CONNECTION LIMIT connlimit
 
    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
 
    | VALID UNTIL 'timestamp'
 
    | IN ROLE role_name [, ...]
 
    | IN GROUP role_name [, ...]
 
    | ROLE role_name [, ...]
 
    | ADMIN role_name [, ...]
 
    | USER role_name [, ...]
 
    | SYSID uid</pre>
 
 
 
===Examples===
 
 
 
*<code>CREATE ROLE myname WITH LOGIN PASSWORD 'jw8s130F4' VALID UNTIL '2022-01-01';</code>
 
 
 
*<code>CREATE ROLE admin WITH CREATEDB CREATEROLE; </code>
 
 
 
 
 
== Related commands ==
 
*<code>[[ALTER USER]]</code>
 
 
 
==See also==
 
{{PostgreSQL}}
 
 
 
[[Category:PosgreSQL]]
 

Latest revision as of 16:27, 20 September 2024

CREATE ROLE adds a new role to a PostgreSQL database cluster. A role can be considered a user, or group.

Overview[edit]

CREATE ROLE name [ [ WITH ] option [ ... ] ]

where option can be: 

      SUPERUSER | NOSUPERUSER
    | CREATEDB | NOCREATEDB
    | CREATEROLE | NOCREATEROLE
    | CREATEUSER | NOCREATEUSER
    | INHERIT | NOINHERIT
    | LOGIN | NOLOGIN
    | REPLICATION | NOREPLICATION
    | CONNECTION LIMIT connlimit
    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
    | VALID UNTIL 'timestamp'
    | IN ROLE role_name [, ...]
    | IN GROUP role_name [, ...]
    | ROLE role_name [, ...]
    | ADMIN role_name [, ...]
    | USER role_name [, ...]
    | SYSID uid

Examples[edit]

Related[edit]

See also[edit]

Advertising: