3 PostgreSQL documentation
6 <refentry id=
"SQL-DROPROLE">
8 <refentrytitle id=
"SQL-DROPROLE-TITLE">DROP ROLE
</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements
</refmiscinfo>
14 <refname>DROP ROLE
</refname>
15 <refpurpose>remove a database role
</refpurpose>
18 <indexterm zone=
"sql-droprole">
19 <primary>DROP ROLE
</primary>
24 DROP ROLE [ IF EXISTS ]
<replaceable class=
"PARAMETER">name
</replaceable> [, ...]
29 <title>Description
</title>
32 <command>DROP ROLE
</command> removes the specified role(s).
33 To drop a superuser role, you must be a superuser yourself;
34 to drop non-superuser roles, you must have
<literal>CREATEROLE<
/>
39 A role cannot be removed if it is still referenced in any database
40 of the cluster; an error will be raised if so. Before dropping the role,
41 you must drop all the objects it owns (or reassign their ownership)
42 and revoke any privileges the role has been granted. The
<xref
43 linkend=
"sql-reassign-owned" endterm=
"sql-reassign-owned-title">
44 and
<xref linkend=
"sql-drop-owned" endterm=
"sql-drop-owned-title">
45 commands can be useful for this purpose.
49 However, it is not necessary to remove role memberships involving
50 the role;
<command>DROP ROLE<
/> automatically revokes any memberships
51 of the target role in other roles, and of other roles in the target role.
52 The other roles are not dropped nor otherwise affected.
57 <title>Parameters
</title>
61 <term><literal>IF EXISTS
</literal></term>
64 Do not throw an error if the role does not exist. A notice is issued
71 <term><replaceable class=
"PARAMETER">name
</replaceable></term>
74 The name of the role to remove.
85 <productname>PostgreSQL
</productname> includes a program
<xref
86 linkend=
"APP-DROPUSER" endterm=
"APP-DROPUSER-title"> that has the
87 same functionality as this command (in fact, it calls this command)
88 but can be run from the command shell.
93 <title>Examples
</title>
104 <title>Compatibility
</title>
107 The SQL standard defines
<command>DROP ROLE
</command>, but it allows
108 only one role to be dropped at a time, and it specifies different
109 privilege requirements than
<productname>PostgreSQL
</productname> uses.
114 <title>See Also
</title>
116 <simplelist type=
"inline">
117 <member><xref linkend=
"sql-createrole" endterm=
"sql-createrole-title"></member>
118 <member><xref linkend=
"sql-alterrole" endterm=
"sql-alterrole-title"></member>
119 <member><xref linkend=
"sql-set-role" endterm=
"sql-set-role-title"></member>