]> granicus.if.org Git - postgresql/blob - doc/src/sgml/ref/drop_role.sgml
Create a "sort support" interface API for faster sorting.
[postgresql] / doc / src / sgml / ref / drop_role.sgml
1 <!--
2 doc/src/sgml/ref/drop_role.sgml
3 PostgreSQL documentation
4 -->
5
6 <refentry id="SQL-DROPROLE">
7  <refmeta>
8   <refentrytitle>DROP ROLE</refentrytitle>
9   <manvolnum>7</manvolnum>
10   <refmiscinfo>SQL - Language Statements</refmiscinfo>
11  </refmeta>
12
13  <refnamediv>
14   <refname>DROP ROLE</refname>
15   <refpurpose>remove a database role</refpurpose>
16  </refnamediv>
17
18  <indexterm zone="sql-droprole">
19   <primary>DROP ROLE</primary>
20  </indexterm>
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</>
35    privilege.
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. The <xref
43    linkend="sql-reassign-owned">
44    and <xref linkend="sql-drop-owned">
45    commands can be useful for this purpose.
46   </para>
47
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>
55
56  <refsect1>
57   <title>Parameters</title>
58
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>
69
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>
80
81  <refsect1>
82   <title>Notes</title>
83
84   <para>
85    <productname>PostgreSQL</productname> includes a program <xref
86    linkend="APP-DROPUSER"> 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>
91
92  <refsect1>
93   <title>Examples</title>
94
95   <para>
96    To drop a role:
97 <programlisting>
98 DROP ROLE jonathan;
99 </programlisting></para>
100  </refsect1>
101
102  <refsect1>
103   <title>Compatibility</title>
104
105   <para>
106    The SQL standard defines <command>DROP ROLE</command>, but it allows
107    only one role to be dropped at a time, and it specifies different
108    privilege requirements than <productname>PostgreSQL</productname> uses.
109   </para>
110  </refsect1>
111
112  <refsect1>
113   <title>See Also</title>
114
115   <simplelist type="inline">
116    <member><xref linkend="sql-createrole"></member>
117    <member><xref linkend="sql-alterrole"></member>
118    <member><xref linkend="sql-set-role"></member>
119   </simplelist>
120  </refsect1>
121
122 </refentry>