1<!-- 2doc/src/sgml/ref/drop_role.sgml 3PostgreSQL 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> 24DROP 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. 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 <xref linkend="sql-reassign-owned"/> and <xref linkend="sql-drop-owned"/> 44 commands can be useful for this purpose; see <xref linkend="role-removal"/> 45 for more discussion. 46 </para> 47 48 <para> 49 However, it is not necessary to remove role memberships involving 50 the role; <command>DROP ROLE</command> 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> 98DROP 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> 123