| 1 |
<!-- |
| 2 |
doc/src/sgml/ref/drop_role.sgml |
| 3 |
PostgreSQL documentation |
| 4 |
--> |
| 5 |
|
| 6 |
<refentry id="sql-droprole"> |
| 7 |
<indexterm zone="sql-droprole"> |
| 8 |
<primary>DROP ROLE</primary> |
| 9 |
</indexterm> |
| 10 |
|
| 11 |
<refmeta> |
| 12 |
<refentrytitle>DROP ROLE</refentrytitle> |
| 13 |
<manvolnum>7</manvolnum> |
| 14 |
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
| 15 |
</refmeta> |
| 16 |
|
| 17 |
<refnamediv> |
| 18 |
<refname>DROP ROLE</refname> |
| 19 |
<refpurpose>remove a database role</refpurpose> |
| 20 |
</refnamediv> |
| 21 |
|
| 22 |
<refsynopsisdiv> |
| 23 |
<synopsis> |
| 24 |
DROP ROLE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [, ...] |
| 25 |
</synopsis> |
| 26 |
</refsynopsisdiv> |
| 27 |
|
| 28 |
<refsect1> |
| 29 |
<title>Description</title> |
| 30 |
|
| 31 |
<para> |
| 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</literal> |
| 35 |
privilege and have been granted <literal>ADMIN OPTION</literal> on the role. |
| 36 |
</para> |
| 37 |
|
| 38 |
<para> |
| 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 on other objects. |
| 43 |
The <link linkend="sql-reassign-owned"><command>REASSIGN |
| 44 |
OWNED</command></link> and <link linkend="sql-drop-owned"><command>DROP |
| 45 |
OWNED</command></link> |
| 46 |
commands can be useful for this purpose; see <xref linkend="role-removal"/> |
| 47 |
for more discussion. |
| 48 |
</para> |
| 49 |
|
| 50 |
<para> |
| 51 |
However, it is not necessary to remove role memberships involving |
| 52 |
the role; <command>DROP ROLE</command> automatically revokes any memberships |
| 53 |
of the target role in other roles, and of other roles in the target role. |
| 54 |
The other roles are not dropped nor otherwise affected. |
| 55 |
</para> |
| 56 |
</refsect1> |
| 57 |
|
| 58 |
<refsect1> |
| 59 |
<title>Parameters</title> |
| 60 |
|
| 61 |
<variablelist> |
| 62 |
<varlistentry> |
| 63 |
<term><literal>IF EXISTS</literal></term> |
| 64 |
<listitem> |
| 65 |
<para> |
| 66 |
Do not throw an error if the role does not exist. A notice is issued |
| 67 |
in this case. |
| 68 |
</para> |
| 69 |
</listitem> |
| 70 |
</varlistentry> |
| 71 |
|
| 72 |
<varlistentry> |
| 73 |
<term><replaceable class="parameter">name</replaceable></term> |
| 74 |
<listitem> |
| 75 |
<para> |
| 76 |
The name of the role to remove. |
| 77 |
</para> |
| 78 |
</listitem> |
| 79 |
</varlistentry> |
| 80 |
</variablelist> |
| 81 |
</refsect1> |
| 82 |
|
| 83 |
<refsect1> |
| 84 |
<title>Notes</title> |
| 85 |
|
| 86 |
<para> |
| 87 |
<productname>PostgreSQL</productname> includes a program <xref |
| 88 |
linkend="app-dropuser"/> that has the |
| 89 |
same functionality as this command (in fact, it calls this command) |
| 90 |
but can be run from the command shell. |
| 91 |
</para> |
| 92 |
</refsect1> |
| 93 |
|
| 94 |
<refsect1> |
| 95 |
<title>Examples</title> |
| 96 |
|
| 97 |
<para> |
| 98 |
To drop a role: |
| 99 |
<programlisting> |
| 100 |
DROP ROLE jonathan; |
| 101 |
</programlisting></para> |
| 102 |
</refsect1> |
| 103 |
|
| 104 |
<refsect1> |
| 105 |
<title>Compatibility</title> |
| 106 |
|
| 107 |
<para> |
| 108 |
The SQL standard defines <command>DROP ROLE</command>, but it allows |
| 109 |
only one role to be dropped at a time, and it specifies different |
| 110 |
privilege requirements than <productname>PostgreSQL</productname> uses. |
| 111 |
</para> |
| 112 |
</refsect1> |
| 113 |
|
| 114 |
<refsect1> |
| 115 |
<title>See Also</title> |
| 116 |
|
| 117 |
<simplelist type="inline"> |
| 118 |
<member><xref linkend="sql-createrole"/></member> |
| 119 |
<member><xref linkend="sql-alterrole"/></member> |
| 120 |
<member><xref linkend="sql-set-role"/></member> |
| 121 |
</simplelist> |
| 122 |
</refsect1> |
| 123 |
|
| 124 |
</refentry> |