summaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/drop_role.sgml
blob: 9a93da624a5ab8a8e1bbe1da5741729165502fb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!--
doc/src/sgml/ref/drop_role.sgml
PostgreSQL documentation
-->

<refentry id="SQL-DROPROLE">
 <indexterm zone="sql-droprole">
  <primary>DROP ROLE</primary>
 </indexterm>

 <refmeta>
  <refentrytitle>DROP ROLE</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>DROP ROLE</refname>
  <refpurpose>remove a database role</refpurpose>
 </refnamediv>

 <refsynopsisdiv>
<synopsis>
DROP ROLE [ IF EXISTS ] <replaceable class="PARAMETER">name</replaceable> [, ...]
</synopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

  <para>
   <command>DROP ROLE</command> removes the specified role(s).
   To drop a superuser role, you must be a superuser yourself;
   to drop non-superuser roles, you must have <literal>CREATEROLE</>
   privilege.
  </para>

  <para>
   A role cannot be removed if it is still referenced in any database
   of the cluster; an error will be raised if so.  Before dropping the role,
   you must drop all the objects it owns (or reassign their ownership)
   and revoke any privileges the role has been granted. The <xref
   linkend="sql-reassign-owned">
   and <xref linkend="sql-drop-owned">
   commands can be useful for this purpose.
  </para>

  <para>
   However, it is not necessary to remove role memberships involving
   the role; <command>DROP ROLE</> automatically revokes any memberships
   of the target role in other roles, and of other roles in the target role.
   The other roles are not dropped nor otherwise affected.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>
   <varlistentry>
    <term><literal>IF EXISTS</literal></term>
    <listitem>
     <para>
      Do not throw an error if the role does not exist. A notice is issued
      in this case.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable class="PARAMETER">name</replaceable></term>
    <listitem>
     <para>
      The name of the role to remove.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1>
  <title>Notes</title>

  <para>
   <productname>PostgreSQL</productname> includes a program <xref
   linkend="APP-DROPUSER"> that has the
   same functionality as this command (in fact, it calls this command)
   but can be run from the command shell.
  </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   To drop a role:
<programlisting>
DROP ROLE jonathan;
</programlisting></para>
 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   The SQL standard defines <command>DROP ROLE</command>, but it allows
   only one role to be dropped at a time, and it specifies different
   privilege requirements than <productname>PostgreSQL</productname> uses.
  </para>
 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-createrole"></member>
   <member><xref linkend="sql-alterrole"></member>
   <member><xref linkend="sql-set-role"></member>
  </simplelist>
 </refsect1>

</refentry>