2 .\" Title: DROP DATABASE
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "DROP DATABASE" "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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 DROP_DATABASE \- remove a database
35 DROP DATABASE [ IF EXISTS ] \fIname\fR [ [ WITH ] ( \fIoption\fR [, \&.\&.\&.] ) ]
37 where \fIoption\fR can be:
44 drops a database\&. It removes the catalog entries for the database and deletes the directory containing the data\&. It can only be executed by the database owner\&. It cannot be executed while you are connected to the target database\&. (Connect to
46 or any other database to issue this command\&.) Also, if anyone else is connected to the target database, this command will fail unless you use the
48 option described below\&.
51 cannot be undone\&. Use it with care!
56 Do not throw an error if the database does not exist\&. A notice is issued in this case\&.
61 The name of the database to remove\&.
66 Attempt to terminate all existing connections to the target database\&. It doesn\*(Aqt terminate if prepared transactions, active logical replication slots or subscriptions are present in the target database\&.
68 This terminates background worker connections and connections that the current user has permission to terminate with
69 \fBpg_terminate_backend\fR, described in
70 Section\ \&9.28.2\&. If connections would remain, this command will fail\&.
75 cannot be executed inside a transaction block\&.
77 This command cannot be executed while connected to the target database\&. Thus, it might be more convenient to use the program
79 instead, which is a wrapper around this command\&.
84 statement in the SQL standard\&.
86 CREATE DATABASE (\fBCREATE_DATABASE\fR(7))