Roles
This section describes the administrative commands pertaining to roles.
Create role
Create a role.
create superuser role name [ extending base [, ...] ]"{" subcommand; [...] "}" ;where subcommand is one ofset password := password
Description
The command create role defines a new database role.
superuser
If specified, the created role will have the superuser status, and will be exempt from all permission checks. Currently, the superuser qualifier is mandatory, i.e. it is not possible to create non-superuser roles for now.
name
The name of the role to create.
extending base [, …]
If specified, declares the parent roles for this role. The role inherits all the privileges of the parents.
The following subcommands are allowed in the create role block:
set password := password
Set the password for the role.
Examples
Create a new role:
create role alice {set password := 'wonderland';};
Alter role
Alter an existing role.
alter role name "{" subcommand; [...] "}" ;where subcommand is one ofrename to newnameset password := passwordextending ...
Description
The command alter role changes the settings of an existing role.
name
The name of the role to alter.
The following subcommands are allowed in the alter role block:
rename to newname
Change the name of the role to newname.
extending …
Alter the role parent list. The full syntax of this subcommand is:
extending name [, ...][ first | last | before parent | after parent ]
This subcommand makes the role a child of the specified list of parent roles. The role inherits all the privileges of the parents.
It is possible to specify the position in the parent list using the following optional keywords:
first– insert parent(s) at the beginning of the parent list,last– insert parent(s) at the end of the parent list,before <parent>– insert parent(s) before an existing parent,after <parent>– insert parent(s) after an existing parent.
Examples
Alter a role:
alter role alice {set password := 'new password';};
Drop role
Remove a role.
drop role name ;
Description
The command drop role removes an existing role.
Examples
Remove a role:
drop role alice;