Database Reference
In-Depth Information
There's more...
Checking roles of a user
pguser=# \du tim
List of roles
Role name | Attributes | Member of
-----------+-------------+-----------
tim | Superuser | {}
: Create role
: Create DB
pguser=# \du bob
List of roles
Role name | Attributes | Member of
-----------+------------ +-----------
bob | Create DB | {}
CREATE USER and CREATE GROUP
Starting from Version 8.x, the commands
CREATE
USER
and
CREATE
GROUP
are actually
variations of
CREATE
ROLE
.
CREATE
USER
u; is equivalent to
CREATE
ROLE
u
LOGIN
; and
CREATE
GROUP
g; is equivalent
to
CREATE
ROLE
g
NOLOGIN
;
Temporarily preventing a user from
connecting
Sometimes you need to temporarily revoke user's connection rights without actually deleting
the user or changing the user's password.
This recipe presents ways to do this.
Getting ready
To modify other users, you must either be a superuser or have the
CREATEROLE
privilege (in
the latter case only non-superuser roles can be altered).
How to do it...
To temporarily prevent the user from logging in, run the following:
pguser=# alter user bob nologin;
ALTER ROLE