1DROPDB(1)                PostgreSQL 13.4 Documentation               DROPDB(1)
2
3
4

NAME

6       dropdb - remove a PostgreSQL database
7

SYNOPSIS

9       dropdb [connection-option...] [option...] dbname
10

DESCRIPTION

12       dropdb destroys an existing PostgreSQL database. The user who executes
13       this command must be a database superuser or the owner of the database.
14
15       dropdb is a wrapper around the SQL command DROP DATABASE
16       (DROP_DATABASE(7)). There is no effective difference between dropping
17       databases via this utility and via other methods for accessing the
18       server.
19

OPTIONS

21       dropdb accepts the following command-line arguments:
22
23       dbname
24           Specifies the name of the database to be removed.
25
26       -e
27       --echo
28           Echo the commands that dropdb generates and sends to the server.
29
30       -f
31       --force
32           Attempt to terminate all existing connections to the target
33           database before dropping it. See DROP DATABASE (DROP_DATABASE(7))
34           for more information on this option.
35
36       -i
37       --interactive
38           Issues a verification prompt before doing anything destructive.
39
40       -V
41       --version
42           Print the dropdb version and exit.
43
44       --if-exists
45           Do not throw an error if the database does not exist. A notice is
46           issued in this case.
47
48       -?
49       --help
50           Show help about dropdb command line arguments, and exit.
51
52       dropdb also accepts the following command-line arguments for connection
53       parameters:
54
55       -h host
56       --host=host
57           Specifies the host name of the machine on which the server is
58           running. If the value begins with a slash, it is used as the
59           directory for the Unix domain socket.
60
61       -p port
62       --port=port
63           Specifies the TCP port or local Unix domain socket file extension
64           on which the server is listening for connections.
65
66       -U username
67       --username=username
68           User name to connect as.
69
70       -w
71       --no-password
72           Never issue a password prompt. If the server requires password
73           authentication and a password is not available by other means such
74           as a .pgpass file, the connection attempt will fail. This option
75           can be useful in batch jobs and scripts where no user is present to
76           enter a password.
77
78       -W
79       --password
80           Force dropdb to prompt for a password before connecting to a
81           database.
82
83           This option is never essential, since dropdb will automatically
84           prompt for a password if the server demands password
85           authentication. However, dropdb will waste a connection attempt
86           finding out that the server wants a password. In some cases it is
87           worth typing -W to avoid the extra connection attempt.
88
89       --maintenance-db=dbname
90           Specifies the name of the database to connect to in order to drop
91           the target database. If not specified, the postgres database will
92           be used; if that does not exist (or is the database being dropped),
93           template1 will be used. This can be a connection string. If so,
94           connection string parameters will override any conflicting command
95           line options.
96

ENVIRONMENT

98       PGHOST
99       PGPORT
100       PGUSER
101           Default connection parameters
102
103       PG_COLOR
104           Specifies whether to use color in diagnostic messages. Possible
105           values are always, auto and never.
106
107       This utility, like most other PostgreSQL utilities, also uses the
108       environment variables supported by libpq (see Section 33.14).
109

DIAGNOSTICS

111       In case of difficulty, see DROP DATABASE (DROP_DATABASE(7)) and psql(1)
112       for discussions of potential problems and error messages. The database
113       server must be running at the targeted host. Also, any default
114       connection settings and environment variables used by the libpq
115       front-end library will apply.
116

EXAMPLES

118       To destroy the database demo on the default database server:
119
120           $ dropdb demo
121
122       To destroy the database demo using the server on host eden, port 5000,
123       with verification and a peek at the underlying command:
124
125           $ dropdb -p 5000 -h eden -i -e demo
126           Database "demo" will be permanently deleted.
127           Are you sure? (y/n) y
128           DROP DATABASE demo;
129

SEE ALSO

131       createdb(1), DROP DATABASE (DROP_DATABASE(7))
132
133
134
135PostgreSQL 13.4                      2021                            DROPDB(1)
Impressum