]> begriffs open source - ai-pg/blob - full-docs/txt/sql-dropdatabase.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-dropdatabase.txt
1
2 DROP DATABASE
3
4    DROP DATABASE — remove a database
5
6 Synopsis
7
8 DROP DATABASE [ IF EXISTS ] name [ [ WITH ] ( option [, ...] ) ]
9
10 where option can be:
11
12     FORCE
13
14 Description
15
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
26 Parameters
27
28    IF EXISTS
29           Do not throw an error if the database does not exist. A notice
30           is issued in this case.
31
32    name
33           The name of the database to remove.
34
35    FORCE
36           Attempt to terminate all existing connections to the target
37           database. It doesn't terminate if prepared transactions, active
38           logical replication slots or subscriptions are present in the
39           target database.
40
41           This terminates background worker connections and connections
42           that the current user has permission to terminate with
43           pg_terminate_backend, described in Section 9.28.2. If
44           connections would remain, this command will fail.
45
46 Notes
47
48    DROP DATABASE cannot be executed inside a transaction block.
49
50    This command cannot be executed while connected to the target database.
51    Thus, it might be more convenient to use the program dropdb instead,
52    which is a wrapper around this command.
53
54 Compatibility
55
56    There is no DROP DATABASE statement in the SQL standard.
57
58 See Also
59
60    CREATE DATABASE