Difference between revisions of "PostgreSQL: CREATE ROLE"

From wikieduonline
Jump to navigation Jump to search
Line 4: Line 4:
 
==Overview==
 
==Overview==
 
* https://www.postgresql.org/docs/14/sql-createrole.html
 
* https://www.postgresql.org/docs/14/sql-createrole.html
<pre>CREATE ROLE name [ [ WITH ] option [ ... ] ]
+
CREATE ROLE name [ [ WITH ] option [ ... ] ]
 
+
where option can be:
+
where option can be:  
 
+
      SUPERUSER | NOSUPERUSER
+
      SUPERUSER | NOSUPERUSER
    | CREATEDB | NOCREATEDB
+
    | CREATEDB | NOCREATEDB
    | CREATEROLE | NOCREATEROLE
+
    | CREATEROLE | NOCREATEROLE
    | CREATEUSER | NOCREATEUSER
+
    | CREATEUSER | NOCREATEUSER
    | INHERIT | NOINHERIT
+
    | INHERIT | NOINHERIT
    | LOGIN | [[NOLOGIN]]
+
    | LOGIN | [[NOLOGIN]]
    | REPLICATION | NOREPLICATION
+
    | REPLICATION | NOREPLICATION
    | CONNECTION LIMIT connlimit
+
    | CONNECTION LIMIT connlimit
    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
+
    | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password'
    | VALID UNTIL 'timestamp'
+
    | VALID UNTIL 'timestamp'
    | IN ROLE role_name [, ...]
+
    | IN ROLE role_name [, ...]
    | IN GROUP role_name [, ...]
+
    | IN GROUP role_name [, ...]
    | ROLE role_name [, ...]
+
    | ROLE role_name [, ...]
    | ADMIN role_name [, ...]
+
    | ADMIN role_name [, ...]
    | USER role_name [, ...]
+
    | USER role_name [, ...]
    | SYSID uid</pre>
+
    | SYSID uid
  
 
===Examples===
 
===Examples===

Revision as of 11:44, 20 April 2022


Overview

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

  • CREATE ROLE my_username WITH LOGIN PASSWORD 'jw8s130F4' VALID UNTIL '2022-01-01';
  • CREATE ROLE my_username WITH CREATEDB CREATEROLE;
  • CREATE ROLE my_username NOLOGIN

Related commands

See also

Advertising: