1DROP DATABASE(7) PostgreSQL 13.3 Documentation DROP DATABASE(7)
2
3
4
6 DROP_DATABASE - remove a database
7
9 DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ]
10
11 where option can be:
12
13 FORCE
14
16 DROP DATABASE drops a database. It removes the catalog entries for the
17 database and deletes the directory containing the data. It can only be
18 executed by the database owner. It cannot be executed while you are
19 connected to the target database. (Connect to postgres or any other
20 database to issue this command.) Also, if anyone else is connected to
21 the target database, this command will fail unless you use the FORCE
22 option described below.
23
24 DROP DATABASE cannot be undone. Use it with care!
25
27 IF EXISTS
28 Do not throw an error if the database does not exist. A notice is
29 issued in this case.
30
31 name
32 The name of the database to remove.
33
34 FORCE
35 Attempt to terminate all existing connections to the target
36 database. It doesn't terminate if prepared transactions, active
37 logical replication slots or subscriptions are present in the
38 target database.
39
40 This will fail if the current user has no permissions to terminate
41 other connections. Required permissions are the same as with
42 pg_terminate_backend, described in Section 9.27.2. This will also
43 fail if we are not able to terminate connections.
44
46 DROP DATABASE cannot be executed inside a transaction block.
47
48 This command cannot be executed while connected to the target database.
49 Thus, it might be more convenient to use the program dropdb(1) instead,
50 which is a wrapper around this command.
51
53 There is no DROP DATABASE statement in the SQL standard.
54
56 CREATE DATABASE (CREATE_DATABASE(7))
57
58
59
60PostgreSQL 13.3 2021 DROP DATABASE(7)