1DROPDB(1)                PostgreSQL 11.3 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       -i
31       --interactive
32           Issues a verification prompt before doing anything destructive.
33
34       -V
35       --version
36           Print the dropdb version and exit.
37
38       --if-exists
39           Do not throw an error if the database does not exist. A notice is
40           issued in this case.
41
42       -?
43       --help
44           Show help about dropdb command line arguments, and exit.
45
46       dropdb also accepts the following command-line arguments for connection
47       parameters:
48
49       -h host
50       --host=host
51           Specifies the host name of the machine on which the server is
52           running. If the value begins with a slash, it is used as the
53           directory for the Unix domain socket.
54
55       -p port
56       --port=port
57           Specifies the TCP port or local Unix domain socket file extension
58           on which the server is listening for connections.
59
60       -U username
61       --username=username
62           User name to connect as.
63
64       -w
65       --no-password
66           Never issue a password prompt. If the server requires password
67           authentication and a password is not available by other means such
68           as a .pgpass file, the connection attempt will fail. This option
69           can be useful in batch jobs and scripts where no user is present to
70           enter a password.
71
72       -W
73       --password
74           Force dropdb to prompt for a password before connecting to a
75           database.
76
77           This option is never essential, since dropdb will automatically
78           prompt for a password if the server demands password
79           authentication. However, dropdb will waste a connection attempt
80           finding out that the server wants a password. In some cases it is
81           worth typing -W to avoid the extra connection attempt.
82
83       --maintenance-db=dbname
84           Specifies the name of the database to connect to in order to drop
85           the target database. If not specified, the postgres database will
86           be used; if that does not exist (or is the database being dropped),
87           template1 will be used.
88

ENVIRONMENT

90       PGHOST
91       PGPORT
92       PGUSER
93           Default connection parameters
94
95       This utility, like most other PostgreSQL utilities, also uses the
96       environment variables supported by libpq (see Section 34.14).
97

DIAGNOSTICS

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

EXAMPLES

106       To destroy the database demo on the default database server:
107
108           $ dropdb demo
109
110       To destroy the database demo using the server on host eden, port 5000,
111       with verification and a peek at the underlying command:
112
113           $ dropdb -p 5000 -h eden -i -e demo
114           Database "demo" will be permanently deleted.
115           Are you sure? (y/n) y
116           DROP DATABASE demo;
117

SEE ALSO

119       createdb(1), DROP DATABASE (DROP_DATABASE(7))
120
121
122
123PostgreSQL 11.3                      2019                            DROPDB(1)
Impressum