]> begriffs open source - ai-pg/blob - full-docs/man7/DROP_ROLE.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / DROP_ROLE.7
1 '\" t
2 .\"     Title: DROP ROLE
3 .\"    Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
5 .\"      Date: 2025
6 .\"    Manual: PostgreSQL 18.0 Documentation
7 .\"    Source: PostgreSQL 18.0
8 .\"  Language: English
9 .\"
10 .TH "DROP ROLE" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 DROP_ROLE \- remove a database role
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 DROP ROLE [ IF EXISTS ] \fIname\fR [, \&.\&.\&.]
36 .fi
37 .SH "DESCRIPTION"
38 .PP
39 \fBDROP ROLE\fR
40 removes the specified role(s)\&. To drop a superuser role, you must be a superuser yourself; to drop non\-superuser roles, you must have
41 CREATEROLE
42 privilege and have been granted
43 ADMIN OPTION
44 on the role\&.
45 .PP
46 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 on other objects\&. The
47 \fBREASSIGN OWNED\fR
48 and
49 \fBDROP OWNED\fR
50 commands can be useful for this purpose; see
51 Section\ \&21.4
52 for more discussion\&.
53 .PP
54 However, it is not necessary to remove role memberships involving the role;
55 \fBDROP ROLE\fR
56 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\&.
57 .SH "PARAMETERS"
58 .PP
59 IF EXISTS
60 .RS 4
61 Do not throw an error if the role does not exist\&. A notice is issued in this case\&.
62 .RE
63 .PP
64 \fIname\fR
65 .RS 4
66 The name of the role to remove\&.
67 .RE
68 .SH "NOTES"
69 .PP
70 PostgreSQL
71 includes a program
72 \fBdropuser\fR(1)
73 that has the same functionality as this command (in fact, it calls this command) but can be run from the command shell\&.
74 .SH "EXAMPLES"
75 .PP
76 To drop a role:
77 .sp
78 .if n \{\
79 .RS 4
80 .\}
81 .nf
82 DROP ROLE jonathan;
83 .fi
84 .if n \{\
85 .RE
86 .\}
87 .SH "COMPATIBILITY"
88 .PP
89 The SQL standard defines
90 \fBDROP ROLE\fR, but it allows only one role to be dropped at a time, and it specifies different privilege requirements than
91 PostgreSQL
92 uses\&.
93 .SH "SEE ALSO"
94 CREATE ROLE (\fBCREATE_ROLE\fR(7)), ALTER ROLE (\fBALTER_ROLE\fR(7)), SET ROLE (\fBSET_ROLE\fR(7))