]> begriffs open source - ai-pg/blob - full-docs/man1/dropdb.1
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man1 / dropdb.1
1 '\" t
2 .\"     Title: dropdb
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 "DROPDB" "1" "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 dropdb \- remove a PostgreSQL database
32 .SH "SYNOPSIS"
33 .HP \w'\fBdropdb\fR\ 'u
34 \fBdropdb\fR [\fIconnection\-option\fR...] [\fIoption\fR...] \fIdbname\fR
35 .SH "DESCRIPTION"
36 .PP
37 dropdb
38 destroys an existing
39 PostgreSQL
40 database\&. The user who executes this command must be a database superuser or the owner of the database\&.
41 .PP
42 dropdb
43 is a wrapper around the
44 SQL
45 command
46 \fBDROP DATABASE\fR\&. There is no effective difference between dropping databases via this utility and via other methods for accessing the server\&.
47 .SH "OPTIONS"
48 .PP
49 dropdb
50 accepts the following command\-line arguments:
51 .PP
52 \fIdbname\fR
53 .RS 4
54 Specifies the name of the database to be removed\&.
55 .RE
56 .PP
57 \fB\-e\fR
58 .br
59 \fB\-\-echo\fR
60 .RS 4
61 Echo the commands that
62 dropdb
63 generates and sends to the server\&.
64 .RE
65 .PP
66 \fB\-f\fR
67 .br
68 \fB\-\-force\fR
69 .RS 4
70 Attempt to terminate all existing connections to the target database before dropping it\&. See
71 DROP DATABASE (\fBDROP_DATABASE\fR(7))
72 for more information on this option\&.
73 .RE
74 .PP
75 \fB\-i\fR
76 .br
77 \fB\-\-interactive\fR
78 .RS 4
79 Issues a verification prompt before doing anything destructive\&.
80 .RE
81 .PP
82 \fB\-V\fR
83 .br
84 \fB\-\-version\fR
85 .RS 4
86 Print the
87 dropdb
88 version and exit\&.
89 .RE
90 .PP
91 \fB\-\-if\-exists\fR
92 .RS 4
93 Do not throw an error if the database does not exist\&. A notice is issued in this case\&.
94 .RE
95 .PP
96 \fB\-?\fR
97 .br
98 \fB\-\-help\fR
99 .RS 4
100 Show help about
101 dropdb
102 command line arguments, and exit\&.
103 .RE
104 .PP
105 dropdb
106 also accepts the following command\-line arguments for connection parameters:
107 .PP
108 \fB\-h \fR\fB\fIhost\fR\fR
109 .br
110 \fB\-\-host=\fR\fB\fIhost\fR\fR
111 .RS 4
112 Specifies the host name of the machine on which the server is running\&. If the value begins with a slash, it is used as the directory for the Unix domain socket\&.
113 .RE
114 .PP
115 \fB\-p \fR\fB\fIport\fR\fR
116 .br
117 \fB\-\-port=\fR\fB\fIport\fR\fR
118 .RS 4
119 Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections\&.
120 .RE
121 .PP
122 \fB\-U \fR\fB\fIusername\fR\fR
123 .br
124 \fB\-\-username=\fR\fB\fIusername\fR\fR
125 .RS 4
126 User name to connect as\&.
127 .RE
128 .PP
129 \fB\-w\fR
130 .br
131 \fB\-\-no\-password\fR
132 .RS 4
133 Never issue a password prompt\&. If the server requires password authentication and a password is not available by other means such as a
134 \&.pgpass
135 file, the connection attempt will fail\&. This option can be useful in batch jobs and scripts where no user is present to enter a password\&.
136 .RE
137 .PP
138 \fB\-W\fR
139 .br
140 \fB\-\-password\fR
141 .RS 4
142 Force
143 dropdb
144 to prompt for a password before connecting to a database\&.
145 .sp
146 This option is never essential, since
147 dropdb
148 will automatically prompt for a password if the server demands password authentication\&. However,
149 dropdb
150 will waste a connection attempt finding out that the server wants a password\&. In some cases it is worth typing
151 \fB\-W\fR
152 to avoid the extra connection attempt\&.
153 .RE
154 .PP
155 \fB\-\-maintenance\-db=\fR\fB\fIdbname\fR\fR
156 .RS 4
157 Specifies the name of the database to connect to in order to drop the target database\&. If not specified, the
158 postgres
159 database will be used; if that does not exist (or is the database being dropped),
160 template1
161 will be used\&. This can be a
162 connection string\&. If so, connection string parameters will override any conflicting command line options\&.
163 .RE
164 .SH "ENVIRONMENT"
165 .PP
166 \fBPGHOST\fR
167 .br
168 \fBPGPORT\fR
169 .br
170 \fBPGUSER\fR
171 .RS 4
172 Default connection parameters
173 .RE
174 .PP
175 \fBPG_COLOR\fR
176 .RS 4
177 Specifies whether to use color in diagnostic messages\&. Possible values are
178 always,
179 auto
180 and
181 never\&.
182 .RE
183 .PP
184 This utility, like most other
185 PostgreSQL
186 utilities, also uses the environment variables supported by
187 libpq
188 (see
189 Section\ \&32.15)\&.
190 .SH "DIAGNOSTICS"
191 .PP
192 In case of difficulty, see
193 DROP DATABASE (\fBDROP_DATABASE\fR(7))
194 and
195 \fBpsql\fR(1)
196 for discussions of potential problems and error messages\&. The database server must be running at the targeted host\&. Also, any default connection settings and environment variables used by the
197 libpq
198 front\-end library will apply\&.
199 .SH "EXAMPLES"
200 .PP
201 To destroy the database
202 demo
203 on the default database server:
204 .sp
205 .if n \{\
206 .RS 4
207 .\}
208 .nf
209 $ \fBdropdb demo\fR
210 .fi
211 .if n \{\
212 .RE
213 .\}
214 .PP
215 To destroy the database
216 demo
217 using the server on host
218 eden, port 5000, with verification and a peek at the underlying command:
219 .sp
220 .if n \{\
221 .RS 4
222 .\}
223 .nf
224 $ \fBdropdb \-p 5000 \-h eden \-i \-e demo\fR
225 Database "demo" will be permanently deleted\&.
226 Are you sure? (y/n) \fBy\fR
227 DROP DATABASE demo;
228 .fi
229 .if n \{\
230 .RE
231 .\}
232 .SH "SEE ALSO"
233 \fBcreatedb\fR(1), DROP DATABASE (\fBDROP_DATABASE\fR(7))