]> begriffs open source - ai-pg/blob - full-docs/man7/DROP_DATABASE.7
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / man7 / DROP_DATABASE.7
1 '\" t
2 .\"     Title: DROP DATABASE
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 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 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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_DATABASE \- remove a database
32 .SH "SYNOPSIS"
33 .sp
34 .nf
35 DROP DATABASE [ IF EXISTS ] \fIname\fR [ [ WITH ] ( \fIoption\fR [, \&.\&.\&.] ) ]
36
37 where \fIoption\fR can be:
38
39     FORCE
40 .fi
41 .SH "DESCRIPTION"
42 .PP
43 \fBDROP DATABASE\fR
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
45 postgres
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
47 FORCE
48 option described below\&.
49 .PP
50 \fBDROP DATABASE\fR
51 cannot be undone\&. Use it with care!
52 .SH "PARAMETERS"
53 .PP
54 IF EXISTS
55 .RS 4
56 Do not throw an error if the database does not exist\&. A notice is issued in this case\&.
57 .RE
58 .PP
59 \fIname\fR
60 .RS 4
61 The name of the database to remove\&.
62 .RE
63 .PP
64 FORCE
65 .RS 4
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\&.
67 .sp
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\&.
71 .RE
72 .SH "NOTES"
73 .PP
74 \fBDROP DATABASE\fR
75 cannot be executed inside a transaction block\&.
76 .PP
77 This command cannot be executed while connected to the target database\&. Thus, it might be more convenient to use the program
78 \fBdropdb\fR(1)
79 instead, which is a wrapper around this command\&.
80 .SH "COMPATIBILITY"
81 .PP
82 There is no
83 \fBDROP DATABASE\fR
84 statement in the SQL standard\&.
85 .SH "SEE ALSO"
86 CREATE DATABASE (\fBCREATE_DATABASE\fR(7))