Difference between revisions of "PostgreSQL: CREATE ROLE"
Jump to navigation
Jump to search
Line 26: | Line 26: | ||
=== Examples === | === Examples === | ||
− | * <code>[[CREATE ROLE]] my_username WITH LOGIN PASSWORD ' | + | * <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 WITH CREATEDB [[CREATEROLE]]; </code> | ||
* <code>CREATE ROLE my_username [[NOLOGIN]];</code> | * <code>CREATE ROLE my_username [[NOLOGIN]];</code> |
Revision as of 15:37, 20 September 2024
CREATE ROLE
adds a new role to a PostgreSQL database cluster. A role can be considered a user, or group.
Contents
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 '123456' VALID UNTIL '2022-01-01';
CREATE ROLE my_username WITH CREATEDB CREATEROLE;
CREATE ROLE my_username NOLOGIN;
Related
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
- PostgreSQL: Database roles,
CREATE USER
,CREATE ROLE
,\du, \du+
,create user, Alter user
CREATE [ INDEX | USER | ROLE ]
Advertising: