The code to unlink dropped relations in FinishPreparedTransaction() was
[PostgreSQL.git] / doc / src / sgml / ref / drop_role.sgml
blob4d647919ebcdd35a5be68a3ce3c102212892c344
1 <!--
2 $PostgreSQL$
3 PostgreSQL documentation
4 -->
6 <refentry id="SQL-DROPROLE">
7 <refmeta>
8 <refentrytitle id="SQL-DROPROLE-TITLE">DROP ROLE</refentrytitle>
9 <manvolnum>7</manvolnum>
10 <refmiscinfo>SQL - Language Statements</refmiscinfo>
11 </refmeta>
13 <refnamediv>
14 <refname>DROP ROLE</refname>
15 <refpurpose>remove a database role</refpurpose>
16 </refnamediv>
18 <indexterm zone="sql-droprole">
19 <primary>DROP ROLE</primary>
20 </indexterm>
22 <refsynopsisdiv>
23 <synopsis>
24 DROP ROLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...]
25 </synopsis>
26 </refsynopsisdiv>
28 <refsect1>
29 <title>Description</title>
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</>
35 privilege.
36 </para>
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. 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.
46 </para>
48 <para>
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.
53 </para>
54 </refsect1>
56 <refsect1>
57 <title>Parameters</title>
59 <variablelist>
60 <varlistentry>
61 <term><literal>IF EXISTS</literal></term>
62 <listitem>
63 <para>
64 Do not throw an error if the role does not exist. A notice is issued
65 in this case.
66 </para>
67 </listitem>
68 </varlistentry>
70 <varlistentry>
71 <term><replaceable class="PARAMETER">name</replaceable></term>
72 <listitem>
73 <para>
74 The name of the role to remove.
75 </para>
76 </listitem>
77 </varlistentry>
78 </variablelist>
79 </refsect1>
81 <refsect1>
82 <title>Notes</title>
84 <para>
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.
89 </para>
90 </refsect1>
92 <refsect1>
93 <title>Examples</title>
95 <para>
96 To drop a role:
97 <programlisting>
98 DROP ROLE jonathan;
99 </programlisting>
100 </para>
101 </refsect1>
103 <refsect1>
104 <title>Compatibility</title>
106 <para>
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.
110 </para>
111 </refsect1>
113 <refsect1>
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>
120 </simplelist>
121 </refsect1>
123 </refentry>