1DROP ROLE() SQL Commands DROP ROLE()
2
3
4
6 DROP ROLE - remove a database role
7
8
10 DROP ROLE [ IF EXISTS ] name [, ...]
11
12
14 DROP ROLE removes the specified role(s). To drop a superuser role, you
15 must be a superuser yourself; to drop non-superuser roles, you must
16 have CREATEROLE privilege.
17
18 A role cannot be removed if it is still referenced in any database of
19 the cluster; an error will be raised if so. Before dropping the role,
20 you must drop all the objects it owns (or reassign their ownership) and
21 revoke any privileges the role has been granted. The REASSIGN OWNED
22 [reassign_owned(7)] and DROP OWNED [drop_owned(7)] commands can be use‐
23 ful for this purpose.
24
25 However, it is not necessary to remove role memberships involving the
26 role; DROP ROLE automatically revokes any memberships of the target
27 role in other roles, and of other roles in the target role. The other
28 roles are not dropped nor otherwise affected.
29
31 IF EXISTS
32 Do not throw an error if the role does not exist. A notice is
33 issued in this case.
34
35 name The name of the role to remove.
36
38 PostgreSQL includes a program dropuser [dropuser(1)] that has the same
39 functionality as this command (in fact, it calls this command) but can
40 be run from the command shell.
41
43 To drop a role:
44
45 DROP ROLE jonathan;
46
47
49 The SQL standard defines DROP ROLE, but it allows only one role to be
50 dropped at a time, and it specifies different privilege requirements
51 than PostgreSQL uses.
52
54 CREATE ROLE [create_role(7)], ALTER ROLE [alter_role(l)], SET ROLE
55 [set_role(l)]
56
57
58
59SQL - Language Statements 2008-06-08 DROP ROLE()