Difference between revisions of "PostgreSQL: CREATE ROLE"
Jump to navigation
Jump to search
m (Welcome moved page CREATE ROLE to PostgreSQL: CREATE ROLE) |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | * <code>[[CREATE | + | * <code>[[CREATE]] ROLE</code> adds a new [[role]] to a [[PostgreSQL]] database [[cluster]]. A role can be considered a [[user]], or [[group]]. |
Line 8: | Line 8: | ||
where option can be: | where option can be: | ||
− | SUPERUSER | NOSUPERUSER | + | [[SUPERUSER]] | NOSUPERUSER |
− | | CREATEDB | NOCREATEDB | + | | [[CREATEDB]] | NOCREATEDB |
| CREATEROLE | NOCREATEROLE | | CREATEROLE | NOCREATEROLE | ||
| CREATEUSER | NOCREATEUSER | | CREATEUSER | NOCREATEUSER | ||
Line 25: | Line 25: | ||
| SYSID uid | | SYSID uid | ||
− | ===Examples=== | + | === Examples === |
− | * <code>CREATE ROLE my_username WITH LOGIN PASSWORD 'jw8s130F4' VALID UNTIL '2022-01-01';</code> | + | * <code>[[CREATE ROLE]] my_username WITH LOGIN PASSWORD 'jw8s130F4' VALID UNTIL '2022-01-01';</code> |
− | * <code>CREATE ROLE my_username WITH CREATEDB CREATEROLE; </code> | + | * <code>CREATE ROLE my_username WITH CREATEDB [[CREATEROLE]]; </code> |
* <code>CREATE ROLE my_username [[NOLOGIN]];</code> | * <code>CREATE ROLE my_username [[NOLOGIN]];</code> | ||
− | == Related | + | == Related == |
* <code>[[ALTER USER]]</code> | * <code>[[ALTER USER]]</code> | ||
− | * <code>[[CREATE USER]]</code> | + | * <code>[[PostgreSQL: CREATE USER]]</code> |
* [[PostgreSQL: Database roles]] | * [[PostgreSQL: Database roles]] | ||
− | * <code>GRANT your_username_origin TO your_new_username_with_same_privileges;</code> | + | * <code>[[GRANT]] your_username_origin TO your_new_username_with_same_privileges;</code> |
* <code>[[useradd]]</code> | * <code>[[useradd]]</code> | ||
* [[List users]]: <code>[[\du]]</code> | * [[List users]]: <code>[[\du]]</code> | ||
+ | * [[ERROR: role "your role" does not exist]] | ||
+ | * [[EOF]] | ||
+ | * [[PostgreSQL users]] | ||
== See also == | == See also == | ||
* {{Role}} | * {{Role}} | ||
− | * {{ | + | * {{CREATE}} |
− | |||
[[Category: PosgreSQL]] | [[Category: PosgreSQL]] | ||
[[Category: SQL]] | [[Category: SQL]] |
Latest revision as of 10:22, 11 July 2023
CREATE ROLE
adds a new role to a PostgreSQL database cluster. A role can be considered a user, or group.
Contents
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]
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[edit]
ALTER USER
PostgreSQL: CREATE USER
- PostgreSQL: Database roles
GRANT your_username_origin TO your_new_username_with_same_privileges;
useradd
- List users:
\du
- ERROR: role "your role" does not exist
- EOF
- PostgreSQL users
See also[edit]
Advertising: